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] - Font color in Bordered select is always gray #3659

Closed
Rain-YuXia opened this issue Aug 16, 2024 · 7 comments · Fixed by #3663
Closed

[BUG] - Font color in Bordered select is always gray #3659

Rain-YuXia opened this issue Aug 16, 2024 · 7 comments · Fixed by #3663
Labels
✨ Type: Enhancement New enhancement on existing codebase

Comments

@Rain-YuXia
Copy link

Rain-YuXia commented Aug 16, 2024

NextUI Version

2.4.6

Describe the bug

Just came to NextUI for a few days. I have a bordered select. I found out the font color is always gray no matter what color props
Screenshot 2024-08-16 at 2 40 47 PM

As you can see, it's still gray even I set the color="primary". It makes the font color inconsistent since the font color in Input is black while the font color in Select is gray

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

<Select
  name="role_id"
  label="Job Role"
  labelPlacement="outside"
  startContent={
      <UserCircleIcon className="w-4 h-4 text-default-400 pointer-events-none" />
  }
  variant="bordered"
  color='primary'
  placeholder="Select your role"
  onChange={(e) => setData('role_id', e.target.value)}
>
  {roles.map(role => (
      <SelectItem key={role}>
          {role}
      </SelectItem>
  ))}
</Select>

Expected behavior

The color should be consistent or is there any way to change the color in Select?

Screenshots or Videos

No response

Operating System Version

Mac

Browser

Chrome

Copy link

linear bot commented Aug 16, 2024

@macci001
Copy link
Contributor

macci001 commented Aug 16, 2024

Hi,
The color=primary will apply only to the label not the selected value and selectable values list in popover.

You can add the class: classNames: { "popoverContent": "text-primary", "value": "text-primary" }
Here, the styling in value applies to the selected value and styling in popoverContent is applied to selectable values.

  • Adding the above class might help you get:
    Screenshot 2024-08-16 at 10 39 28 AM
  • If you like to have custom color for the selected value, you can add the classNames: { "popoverContent": "text-primary", "value": "text-[#99C7FB]" } class
    Screenshot 2024-08-16 at 10 47 39 AM

@macci001
Copy link
Contributor

macci001 commented Aug 16, 2024

@wingkwong Will it be helpful to edit the bordered variant for this?

@Rain-YuXia
Copy link
Author

Hi, The color=primary will apply only to the label not the selected value and selectable values list in popover.

You can add the class: classNames: { "popoverContent": "text-primary", "value": "text-primary" } Here, the styling in value applies to the selected value and styling in popoverContent is applied to selectable values.

  • Adding the above class might help you get:
    Screenshot 2024-08-16 at 10 39 28 AM
  • If you like to have custom color for the selected value, you can add the classNames: { "popoverContent": "text-primary", "value": "text-[#99C7FB]" } class
    Screenshot 2024-08-16 at 10 47 39 AM

Hi

Thank you for your solution.

It changed the color of selected value as expected. But the cons is that the color of placeholder gets changed as well.

Because the placeholder is not a real placeholder prop in an input, but a span. So I have to do like this: classNames= {{ "value": data ? "text-black" : "text-gray-500" }} as my temporary solution.

But personally, I can't get the point of design in this way. If the Select has no border, the selected value color is the same as other components. Why the selected value will be changed when Select is bordered, making the color inconsistent with other components?

@macci001
Copy link
Contributor

@Rain-YuXia
You can add this {"value: "group-data-[has-value=true]:text-default-foreground"} to avoid using the conditional. This will show text as gray when placeholder is shown and black when some value is selected.

  • when placeholder
    Screenshot 2024-08-16 at 1 58 24 PM
  • when value is selected
    Screenshot 2024-08-16 at 1 58 53 PM

@Rain-YuXia
Copy link
Author

@macci001
working perfectly. Thanks

Is it an undocumented hidden feature? I can't find it anywhere in the documentation.

@macci001
Copy link
Contributor

macci001 commented Aug 19, 2024

@macci001 working perfectly. Thanks

Is it an undocumented hidden feature? I can't find it anywhere in the documentation.

This is just a hack until this bug is fixed.

@wingkwong wingkwong added the ✨ Type: Enhancement New enhancement on existing codebase label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Type: Enhancement New enhancement on existing codebase
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants