I think the best way to change color is using the theme props or in the doc look something like this :
import { flavourOptions } from '../data';
import Select from 'react-select';
export default () => (
<Select
defaultValue={flavourOptions[2]}
label="Single select"
options={flavourOptions}
theme={theme => ({
...theme,
borderRadius: 0,
colors: {
...theme.colors,
primary25: 'hotpink',
primary: 'black',
},
})}
/>
);
but, I am not stuck at figuring out how to "connect" it dark mode togggle..
Here's an example with tailwind css making use of the className and classNamePrefix arguments:
React usage:
<Select
className="my-react-select-container"
classNamePrefix="my-react-select"
...
Tailwind CSS index.css
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
/* .my-react-select-container {
} */
.my-react-select-container .my-react-select__control {
@apply bg-white dark:bg-neutral-700 border-2 border-neutral-300 dark:border-neutral-700 hover:border-neutral-400 dark:hover:border-neutral-500;
}
.my-react-select-container .my-react-select__control--is-focused {
@apply border-neutral-500 hover:border-neutral-500 dark:border-neutral-400 dark:hover:border-neutral-400 shadow-none;
}
.my-react-select-container .my-react-select__menu {
@apply bg-neutral-100 dark:bg-neutral-700 border-2 border-neutral-300 dark:border-neutral-600;
}
.my-react-select-container .my-react-select__option {
@apply text-neutral-600 dark:text-neutral-200 bg-neutral-100 hover:bg-neutral-200 dark:bg-neutral-700 dark:hover:bg-neutral-800;
}
/* .my-react-select-container .my-react-select__option--is-focused {
@apply bg-neutral-200 dark:bg-neutral-800;
} */
.my-react-select-container .my-react-select__indicator-separator {
@apply bg-neutral-400;
}
.my-react-select-container .my-react-select__input-container,
.my-react-select-container .my-react-select__placeholder,
.my-react-select-container .my-react-select__single-value {
@apply text-neutral-600 dark:text-neutral-200;
}
}
Result:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With