Pass props defined in the theme .defaultProps to the components
See original GitHub issue(Opening this ticket so the conversation doesn’t get lost on discord)
Right now only stylistic props in the defaultProps
section of the component theme are used. Any other properties are ignored. (See codesanbox)
There is a bunch of non-stylistic properties that would benefit from being passed to the underlying component. Some examples:
- Being able to set a default openDelay on all tooltips.
- Being able to set all tooltips with
hasArrow
. - Being able to set a default
as
on the different variants/sizes ofHeading
. - Overriding the default aria-label on components like the
CloseButton
(e.g. translating it to other languages).
Right now the only alternative would be to create a custom wrapper component that sets those defaults props.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:38
- Comments:9 (7 by maintainers)
Top Results From Across the Web
A complete guide to React default props - LogRocket Blog
Cover three ways to implement default props in React and provide default values for props that are not required by the component.
Read more >How to pass material-ui's theme object to defaultProps?
I'm just rubber ducking something here. Since I'm still passing backgroundColor as a prop to my Example component I'm just wondering how to ......
Read more >React: Everything about Default Props | by Chidume Nnamdi
In this post, we'll learn all about default props in React. ... defaultProps can be defined as a property on the component class...
Read more >Default props - Mantine
Default props. You can define default props for every Mantine component by setting theme.components on MantineProvider: Within provider.
Read more >Default Values - Styled System
With the default props above, your Card component will have padding and a white background by default. You can override these styles when...
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
Hi all, I know it may be a bit hacky, but I thought it was good to share: you can actually override the
defaultProps
as followsHave a good weekend!
I think this is a great idea. These are valid, common sense use cases. Wrapper components are also the worst.