A more flexible approach to styling react-select ?
See original GitHub issueHi !
I like using react-select, but I am less comfortable with the given possibilities to style the component.
We are supposed to include a css stylesheet to make it work. Which leaves us few choices if we want to deeply customize the component :
- Either overriding stylesheet classes
- Or setting inline style props on the component
It looks ok for most of the cases, but when we want to customize the component more seriously, things become messy real quick.
What if for instance, we want the component to have a variable width and behave like an autosize input ? (If we set width: auto;
to the component, it kind of works but doesn’t make the component fit the whole width of the selected value. – But it might be an other issue on the component styles.
What would be awesome would be to use a BEM approach to define a set of classes respectful to the DOM hierarchy of the component -> Which would be possibly overridden with a “theme” prop.
That would have the good benefit to let users extend styles of the component with css modules, or just using a more clear structure like BEM if he wants to stick with css.
I really like the way react-autowhatever deals with the issue, see : https://github.com/moroshko/react-autosuggest#theme-optional Possibly a good source of inspiration.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:49
- Comments:33 (6 by maintainers)
Top GitHub Comments
styled-components
with theming please.It’s already “relative” easy to change the styling by using styled-components as an example.