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.

Button BaseStyle not overriding for paddings

See original GitHub issue

🐛 Bug report

Provide a brief description of the bug here

Hi, this is similar to #2015. However, this time paddingX and px do not override the button styles.

💥 Steps to reproduce

Clear and concise reproduction steps are important for us to be able to triage your issue in a timely manner

See the _app.js file in the repro

💻 Link to reproduction

Please create a minimal reproduction in CodeSandbox

https://codesandbox.io/s/chakra-button-basestyle-repro-spjid?file=/pages/_app.js

🧐 Expected behavior

Tell us what you expect to happen.

🧭 Possible Solution

Not compulsory, but suggesting a fix would be great!

🌍 System information

Software Version(s)
Chakra UI 1.2.1
Browser Brave
Operating System MacOS

📝 Additional information

  • Screenshots or code
  • Notes or link to ideas

It might be good to check what other props are not being applied, but so far in the repro, the padding in the x direction do not work.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

8reactions
tawnyzhaocommented, Feb 14, 2021

@mtt87 I just had your issue, I realized it is also due to similar reasons as the padding issue here. For buttons, the background color is defined in the variants object, which is by default uses solid. If you override the bg through the variant, this issue no longer occurs. I think this could be more clear in the docs.

3reactions
giedrius-timinskiscommented, Mar 2, 2022

Facing the same issue with Button. Looks like whatever property was used to define the style will need to be used to override it, i.e. per the Button example: https://github.com/chakra-ui/chakra-ui/blob/main/packages/theme/src/components/button.ts#L168

Example: ⛔️ Doesn’t work

extendTheme({
  components: {
    Button: {
      baseStyles: {
        height: 'auto'
      }
    }
  }
});

✅ Works

extendTheme({
  components: {
    Button: {
      baseStyles: {
        h: 'auto'
      }
    }
  }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Chakra UI spacing not matching expected defaults for padding ...
I'm working on converting my app from rebass to chakra and ... const Button: ComponentStyleConfig = { baseStyle: { fontWeight: 'bold', } ...
Read more >
Component Style - Chakra UI
For example, the <Button> component renders a <button> HTML element: ... these styles because the Card component is not a built-in component in...
Read more >
RadButton and Overriding Default styles - Telerik
I tried the example on 'Creating a Custom Skin for RadButton' and still found that not all my changes had overridden the Default...
Read more >
Component Style - Chakra UI
For example, the <Button> component renders a <button> HTML element: ... If no props is passed, the defaultProps defined in the style config...
Read more >
Overriding Default Button Styles | CSS-Tricks
See in the video above how setting border: 0; removed the border in Chrome, but also the background? Not the case in Firefox:...
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