-
Hi, Thanks very much for this library. It is exactly what I was looking for. As you can see, by default the background colour seems to be primary25 of the default select component. And it is not looking nice on dark theme Here is how my select is defined: <Select options={tokens} components={{ Option: IconOption }} />
const IconOption = (props) => (
<components.Option label={props.data.name} {...props}>
<Flex align="center">
<Image
w="20px"
h="20px"
src={`${process.env.PUBLIC_URL}/${props.data.image}`}
alt={props.data.name}
/>
<Text ml="10px">{props.data.name}</Text>
</Flex>
</components.Option>
); I tried to provide a style like this : const chakraStyles: ChakraStylesConfig = {
option: (provided, state) => ({
...provided,
background: state.isFocused ? "teal.100" : provided.background,
}),
}; I also tried to override the default style <Select
theme={(theme) => ({
...theme,
borderRadius: 0,
colors: {
...theme.colors,
primary25: 'red',
},
})}
options={tokens} components={{ Option: IconOption }}
/> Nothing worked. Do you have an idea how to do it please? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I'm glad you like it 😀 So it looks like you are importing the If you'd like to wrap my theme aware option component, try importing it like this: import { Select, chakraComponents } from "chakra-react-select";
const IconOption = (props) => (
<chakraComponents.Option label={props.data.name} {...props}>
<Flex align="center">
<Image
w="20px"
h="20px"
src={`${process.env.PUBLIC_URL}/${props.data.image}`}
alt={props.data.name}
/>
<Text ml="10px">{props.data.name}</Text>
</Flex>
</chakraComponents.Option>
);
export const TokenSelect = () => (
<Select options={tokens} components={{ Option: IconOption }} />
) If you do it this way, the background/text colors will match your light/dark mode. If you're still running into any issues, let me know! Also here's an example implementation of a custom |
Beta Was this translation helpful? Give feedback.
I'm glad you like it 😀
So it looks like you are importing the
components
object that is exported by the original package. I'm currently exporting both that and the custom components used by this package to give people the freedom of using whatever they want from either.If you'd like to wrap my theme aware option component, try importing it like this: