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.primary.color applies background instead of label color

See original GitHub issue

button.primary.color sets background-color, instead of label color

Expected Behavior

button.primary.color sets label color

When setting the color property for button variants, a CSS rule for color should be applied to button element.

Actual Behavior

A background-color rule is applied instead, this making it impossible to overwrite colours for labels in button variants.

Result

Steps to Reproduce

  1. set up your theme
  global: {
    colors: {
      brand: '#A7893D'
    },
    font: {
      family: 'Helvetica'
    }
  },
  button: {
    primary: {
      color: 'salmon'
    }
  }
}
  1. run storybook
  2. see result

Your Environment

  • Grommet version: grommet@2.13.0
  • Browser Name and version: Chrome 81.0.4044.138
  • Operating System and version (desktop or mobile): MacOS Catalina 10.15.4

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
ShimiSuncommented, May 26, 2020

I agree with your comment. I think we should consider having separate color theme props for color and background.color within primary button.

Regardless, please take a look at how I was able to impact the text color of primary button in this code snippet: https://codesandbox.io/s/themed-button-pp77f?file=/index.js

const theme = {
  button: {
    primary: {
      extend: `color: white;`
    },
}
2reactions
mihai-rocommented, May 26, 2020

I’m not sure whether this issue is a bug since we document the primary color as the fill color https://v2.grommet.io/button#color the color that is used for the text is text color https://v2.grommet.io/button#global.colors.text

My issue is not related to the primary colour in the global.colors object, but rather to the button variant called primary - <Button primary {...} />. I am trying to adjust the style for primary buttons, e.g. changing the label colour and its background colour. Now, I can see these being described in the documentation as button.primary.color and button.primary.background.color accordingly. However, changing button.primary.color actually changes the background colour, and button.primary.background.color is being ignored entirely. Am I missing something? According to the documentation, this is not intended behaviour.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Label not change background color when my radio button ...
Check this you need to change the structure 1st input after label there is no way to select direct previous siblings, with your...
Read more >
Bootstrap Buttons: Classes & Styles Explained - HubSpot Blog
Bootstrap button with sage green color defined by CSS class selector ... the CSS style property border-color instead of background-color.
Read more >
Overriding Angular Material Component Colors - Wildcard Corp.
For example, if a blue button was desired but blue was not either the primary or accent color defined in your Material theme,...
Read more >
How to Style the Selected Label of a Radio Button - W3docs
In this snippet, learn how you can style the selected label of a radio button. For that, you need to use the CSS...
Read more >
How to change the background color after clicking the button ...
Given an HTML document and the task is to change the background color of the document using JavaScript and jQuery.
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