Input border radius not overridable via baseStyle
See original GitHub issue🐛 Bug report
I am unable to override Input
’s border radius via theme.compontnts.Input.baseStyle.borderRadius
. However, I am able to override it by passing the borderRadius
prop to the component itself.
💥 Steps to reproduce
- Create an
Input
. - Create a Theme object and pass it to the
Chakra
provider. - Assign
Theme.components.Button.baseStyle.borderRadius
to 0. - Observe no change
- Remove the assignment from step 3.
- Add the
borderRadius
prop toButton
and pass it 0. - Observer change
💻 Link to reproduction
https://codesandbox.io/s/blue-dream-bqwon?file=/src/App.js
🧐 Expected behavior
I expect to be able to set the borderRadius
for an Input
at the theme level.
🌍 System information
Software | Version(s) |
---|---|
Chakra UI | 1.0.2 |
Browser | Firefox 83 |
Operating System | Windows 10 |
📝 Additional information
I am able to set borderRadius
for Button
in the theme and it works as expected.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Input style props not being overwritten with customized theme
baseStyle styles are overridden by sizes styles (borderRadius, fontSize, height & padding) as well as variant styles (background, border, ...
Read more >Chakra: can't override global border style - Stack Overflow
This will override the borderColor property of all elements. The only thing to keep an eye on is that if you define the...
Read more >Override the Built-in Component's Styles in Chakra UI
In this lesson, you'll learn how to override the built-in component's styles. Specifically, you'll change the border radius and outline to ...
Read more >border-radius - CSS: Cascading Style Sheets - MDN Web Docs
The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single radius to make circular corners, ......
Read more >Frontend Handbook | React / Chakra UI - Infinum
Under the hood Chakra UI is using emotion ThemeProvider. Example: ... type scale, font stacks, breakpoints, border radius values, and more.
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
@with-heart Thanks for the response! makes complete sense to me now, thanks for taking the time to explain ❤️
@JClackett If it worked that’d way, it’d break the whole theming system! I don’t think we’ve documented this very well, but the priority for styles is:
__css
<baseStyle
<variant
<size
< props <sx
This allows for a cascading system of styles, where we use
__css
internally to style components with the lowest priority and then layer the other styles on top.baseStyle
has lower priority thanvariant
/size
because if it was higher, then the other two become far less useful as you couldn’t customize any of the props they were using. You’d have to manually unset the props from the base and then add your own on top if you wanted them to be different, which imo would be far more frustrating than the current duplication.The base style essentially just set defaults, and then variants and sizes are customizations on top of that. I can see how that could cause pain in some situations, but not sure how to change that around without breaking the whole model/causing larger pains.