Alert colorScheme's defaultProps is not taken into consideration
See original GitHub issueDescription
Hello,
I wanted to create an alert that has a grey colorScheme by default. But when I try to override Alert’s theme I came across a different behavior than I expected.
Problem Statement/Justification
My need is that:
<Alert>
...
Would render a grey alert. So I went ahead and override Alert’s theme with:
const defaultProps = {
variant: "solid",
colorScheme: "gray", // gray is a valid colorScheme
};
In this case, the solid defaultProps is taken into consideration, but the colorScheme is not. Unfortunately, the underlying code seems to set the colorScheme to “blue” (via STATUS.info) when we don’t explicitly set a colorScheme props.
Proposed Solution or API
I expect
const defaultProps = {
variant: "solid",
colorScheme: "gray", // gray is a valid colorScheme
};
To allow to use Alert without specifying the colorScheme props each time in inline props
Alternatives
No response
Additional Information
Thanks for the great work with Chakra-ui 😄
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Eslint: Problem with default props in functional component ...
Eslint react plugin complain with this error ESLint: propType "gretting" is not required, but has no corresponding defaultProps declaration.( ...
Read more >r/reactjs - React defaultProps is dying, who's the contender?
The main issue is that if we're talking about non primitive default values, they will cause re render of child components if passed....
Read more >Flex UI Configuration | Twilio
Information on how to modify the Twilio Flex UI, using either the Flex Configuration Object or the defaultProps API.
Read more >Breaking changes in v5, part one: styles and themes - MUI
This is a reference guide to all of the breaking changes introduced in Material v5, and how to handle them when migrating from...
Read more >Theming React components with Tailwind CSS
Now create a Button.js file inside that. We'll use the colors we defined in our Tailwind config to define the background and text...
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
Encountering the same issue.
Something like this definitely works for checkbox or buttons etc but for for alert, i still get the default blue.
Hi! This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs within 5 days. Thank you for your contributions.