Unable to apply custom-styles for top menu-portal element via CSS
See original GitHub issueI’m using classNamePrefix="Select"
prop to style inner elements from external css-file.
Everything works fine, except menuPortal
element. It does not receive any specific className and when used in combination with menuPortalTarget={document.body}
it’s impossible to style that top element from portal via .Select__someElemName {}
.
Currently only possible solution to add styles to menuPortal
element is to use inline styles:
<Select
menuPortalTarget={document.body}
styles={{
menuPortal: styles => ({ ...styles, zIndex: 100 }) // >= dialog's z-index
}}
/>
The portal rendered in document.body
has closest human-readable className Select__menu
:
It would be good to have ability to add custom class-names to this menuPortal
element, since it might be rendered outside of <Select/>
component.
Please fix it and thanks for great job! 👍
Issue Analytics
- State:
- Created 5 years ago
- Reactions:25
- Comments:13 (2 by maintainers)
Top Results From Across the Web
How to style react-select options - css - Stack Overflow
react select v2 (update). This new version introduces a new styles-api and some other major changes. Custom Styles.
Read more >Solving the React Error: Not Picking Up CSS Style | Pluralsight
In this guide, you will learn about the errors that can occur while importing a CSS file into your React file.
Read more >How To Style Common Form Elements with CSS - DigitalOcean
This tutorial covers the creation and styling of a web form that requests various data from the user. The form will use text...
Read more >How to Troubleshoot CSS Not Working - WPForms
Have you added custom CSS for your forms, but not been able to see it come through? Here's how to troubleshoot when your...
Read more >chakra-react-select - npm
This key applies to the MenuPortal element which is only used when the menuPortalTarget prop is passed in. This component is replaceable, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A workaround is to add a placeholder in the dom for the react-select-portals and then to apply classes you want to it:
Then specify the portal to the portal placeholder:
Yeah, I don’t see any reason why
MenuPlacer
shouldn’t have the typicalclassname
prop. I made a separate PR for that (https://github.com/JedWatson/react-select/pull/4342) since I’m not sure that it fits in with the existing refactor PR that @ebonow referenced (https://github.com/JedWatson/react-select/pull/4333).