Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing Button Color #65

Open
HanzalaS opened this issue Jun 29, 2020 · 2 comments
Open

Changing Button Color #65

HanzalaS opened this issue Jun 29, 2020 · 2 comments

Comments

@HanzalaS
Copy link

I'm having problems changing the color of the button. I'm not using sass.

@NebuPookins
Copy link

I've found two ways to accomplish this. Which one is easier might depend on your specific use case.

Method 1: Add a New Button Type

This works well if you expect to re-use the same color over and over again.

You can but an arbitrary string in the type attribute, e.g. <AwesomeButton type="plain">Button</AwesomeButton>. The generated HTML will create an element with CSS class name aws-btn--plain.

You can then create a bunch of CSS rules that will style the color for that button. There's a good reference commit illustrating how to do that in michael616kriel@2ccbfd6 but it'll look something like this:

.aws-btn {
  --button-plain-color: #ffffff;
  --button-plain-color-dark: #1360a4;
  --button-plain-color-light: #1E88E5;
  --button-plain-color-hover: #f2f2f2;
  --button-plain-color-active: #e6e6e6;
  --button-plain-border: 2px solid #1E88E5;
}
.aws-btn--plain .aws-btn__wrapper:before {
  background: var(--button-plain-color-dark);
}
.aws-btn--plain .aws-btn__content {
  background: var(--button-plain-color);
  color: var(--button-plain-color-light);
  border: var(--button-plain-border);
}
.aws-btn--plain .aws-btn__content path {
  fill: var(--button-plain-color-light);
}
.aws-btn--plain .aws-btn__wrapper:hover .aws-btn__content {
  background: var(--button-plain-color-hover);
}
.aws-btn--plain.aws-btn--active .aws-btn__wrapper .aws-btn__content {
  background: var(--button-plain-color-active);
}

Method 2: Use Inline CSS to Override the Colors

This works well if you have a single button whose color you want to be a special color.

You can use the style attribute to provide arbitrary CSS overrides, and in particular, you can override the color variables used by the system. It would look something like this:

<AwesomeButton type="secondary" style={{
  '--button-secondary-color': "#ff8585",
  '--button-secondary-color-dark': "#722222",
  '--button-secondary-color-light': "#4b1616",
  '--button-secondary-color-hover': "#ff0000",
  '--button-secondary-color-active': "#ff0505",
}}>Button</AwesomeButton>

@NebuPookins
Copy link

I've added a pull request to add the above information to the official README #98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants