Override option text color in a select component #307
Replies: 1 comment
-
The easiest way to implement this is using the <Select
chakraStyles={{
container: (provided) => ({
...provided,
color: "black",
}),
}}
/> This will also ensure that the controls (clear button and dropdown arrow) also inherit this color: Now, if you're happy with the main control component becoming black when you focus it, this is all you need (you didn't mention anything about this). But it does make things very hard to see, so if you'd like to keep that light colored when you focus as well, add this to your <Select
chakraStyles={{
container: (provided) => ({
...provided,
color: "black",
}),
control: (provided) => ({
...provided,
_focusVisible: {
bg: "white",
},
}),
}}
/> This will ensure that everything is equally visible when your component is focused: Here's a complete CodeSandbox example: https://codesandbox.io/p/sandbox/w9jf8j?file=%2Fcomponents%2Fselect-choc.tsx And next time you have a question, it would be great if you could provide a CodeSandbox with a complete example with your question. It's much easier to provide help if I have a complete example of what you've tried to go off of. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to get black option text without using darkmode...
This is my component:
export default SelectChoc;
However in my main page where i use the component i have this theme. And due to the color: "white", it makes the option text white as well.
Look at these picture:
When showing options available enter
I still want to keep the theme on my page, but somehow make the text for the dropdown options black. Have tried everything. Would love some advice... :)
Cheers!
Beta Was this translation helpful? Give feedback.
All reactions