Skip to content

Commit

Permalink
Merge pull request #2752 from NickColley/change-button-colour
Browse files Browse the repository at this point in the history
Change the Button component background and text colour
  • Loading branch information
querkmachine authored Aug 18, 2022
2 parents c31c4be + cada8cc commit c24387e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

## Unreleased

### New features

#### Change the Button component background and text colour

For non-GOV.UK branded websites, you can now change the Button component background and text colour.

To change the Button component background colour set the `$govuk-button-background-colour` Sass variable.

To change the Button component text colour set the `$govuk-button-text-colour` Sass variable.

```scss
@import "node_modules/govuk-frontend/govuk/base";

$govuk-button-background-colour: govuk-colour("yellow");
$govuk-button-text-colour: govuk-colour("black");
@import "node_modules/govuk-frontend/govuk/components/button/index";
```

This was added in [pull request #2752: Change the Button component background and text colour](https://github.com/alphagov/govuk-frontend/pull/2752). Thanks to [Nick Colley](https://github.com/NickColley) for this contribution.

### Recommended changes

#### Remove `aria-labelledby`, remove `id="error-summary-title"` from title and move `role="alert"` to child container on the error summary component
Expand Down
22 changes: 20 additions & 2 deletions src/govuk/components/button/_index.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
////
/// @group components/button
////

/// Button component background colour
///
/// @type Colour
/// @access public

$govuk-button-background-colour: govuk-colour("green", $legacy: #00823b) !default;

/// Button component text colour
///
/// @type Colour
/// @access public

$govuk-button-text-colour: govuk-colour("white") !default;

@include govuk-exports("govuk/component/button") {
$govuk-button-colour: govuk-colour("green", $legacy: #00823b);
$govuk-button-colour: $govuk-button-background-colour;
$govuk-button-hover-colour: govuk-shade($govuk-button-colour, 20%);
$govuk-button-shadow-colour: govuk-shade($govuk-button-colour, 60%);
$govuk-button-text-colour: govuk-colour("white");
$govuk-button-text-colour: $govuk-button-text-colour;

// Secondary button variables
$govuk-secondary-button-colour: govuk-colour("light-grey", $legacy: "grey-3");
Expand Down
1 change: 1 addition & 0 deletions tasks/sassdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function buildSassdocs (cb) {
sassdoc([paths.src + '**/**/*.scss', `!${paths.src}/vendor/*`], {
dest: paths.sassdoc,
groups: {
'components/button': 'Components / Button',
'helpers/accessibility': 'Helpers / Accessibility',
'helpers/colour': 'Helpers / Colour',
'helpers/layout': 'Helpers / Layout',
Expand Down

0 comments on commit c24387e

Please sign in to comment.