question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

  1. Create an Input.
  2. Create a Theme object and pass it to the Chakra provider.
  3. Assign Theme.components.Button.baseStyle.borderRadius to 0.
  4. Observe no change
  5. Remove the assignment from step 3.
  6. Add the borderRadius prop to Button and pass it 0.
  7. 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:closed
  • Created 3 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
JClackettcommented, Apr 26, 2021

@with-heart Thanks for the response! makes complete sense to me now, thanks for taking the time to explain ❤️

0reactions
with-heartcommented, Apr 26, 2021

@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 than variant/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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found