Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Input Alignment and classNames Styling When Using label in Input Component #2651

Open
drokbers opened this issue Apr 5, 2024 · 2 comments
Labels
🐛 Type: Bug Something isn't working

Comments

@drokbers
Copy link

drokbers commented Apr 5, 2024

NextUI Version

2.2.10

Describe the bug

I am experiencing two interconnected issues with the Input component from @nextui-org/react. Firstly, when a label is used, the input's text alignment is off, with the input text appearing higher up, closer to the label, rather than being vertically centered. This misalignment impacts the visual harmony and usability of the input field.

While attempting to address this alignment issue by adjusting padding and margin through the classNames prop, I discovered that these styles are not applied to the input when a label is present. Removing the label makes the custom styles effective, which indicates that the presence of a label somehow interferes with the application of custom styles specified in classNames.

I tried for both 2.1.13 and 2.2.10 and have the same problem.

My Code:

<Input
  onChange={handleInputChange}
  name="min_salary"
  label="Min Salary"
  className="w-full md:w-custom50"
  classNames={{
    input: "outline-none focus:ring-0 focus:outline-none",   // pt or mp is not working in here if there's label
  }}
  value={values?.min_salary?.toString()}
  placeholder="0.00"
  startContent={
    <div className="pointer-events-none flex items-center">
      <span className="text-default-400 text-small">$</span>
    </div>
  }
  endContent={
    <div className="flex items-center outline-none focus:ring-0 focus:outline-none">
      <select
        className="outline-none focus:ring-0 focus:outline-none border-0 bg-transparent text-default-400 text-small"
        id="currency"
        name="currency"
        value={values?.currency}
        onChange={handleInputChange}
      >
        <option>USD</option>
        <!-- Additional options -->
      </select>
    </div>
  }
  type="number"
/>

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Use the Input component with the label and classNames props.
    2)Observe the vertical alignment issue of the input text, which does not center properly when a label is used.
    3)Apply custom styles such as padding or margin to the input key within the classNames object to correct the alignment.
    4)Notice that the custom styles do not affect the input field as long as the label prop is present.
    5)Remove the label prop and observe that both the alignment looks better and the custom styles apply correctly.

Expected behavior

  • The input text should remain vertically centered within the input field, even when a label is present.

  • Custom styles specified through the classNames prop should be applied to the input element, regardless of the presence of a label.

Screenshots or Videos

image

Operating System Version

macOS

Browser

Chrome

@drokbers drokbers added the 🐛 Type: Bug Something isn't working label Apr 5, 2024
@ryo-manba
Copy link
Member

@drokbers
I couldn't reproduce the issue.
Could you provide a CodeSandbox link or another demo to replicate the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants