Hyvä button colors. How do you check contrast after a palette change?

1 min read

Three blue and violet pieces on a silver base, one with a visible outline

Check button contrast in the target store view after publishing the palette. In the example, the white label measured 6.70:1 by default and 2.98:1 on hover.

Read colors from the rendered button

Use developer tools to check color and background-color at rest, on hover and while pressed. Press Tab to check keyboard focus visibility. This local button uses values generated by Hyvä Colors 0.1.8 and an outline supplied by the test theme. Hyvä Colors documentation.

Color pairs read in Opera
StateText or outlineBackgroundContrast
Default#FFFFFF#1D4ED86.70:1
Hover#FFFFFF#818CF82.98:1
Active, while pressed#FFFFFF#3730A39.93:1
Focus outline against white#6D28D9#FFFFFF7.10:1
Hover after adjustment#FFFFFF#4338CA7.90:1

Use the threshold for the measured pair

For the sample’s regular 16 px label, WCAG 2.2 AA requires at least 4.5:1 against its background. For a custom focus indicator, check the required 3:1 against its adjacent color. The example uses a white gap around the outline. WCAG text contrast · Non-text contrast.

Adjust the affected state and measure again

Changing the hover background to #4338CA brought the ratio to 7.90:1 with the same label color. Repeat the check on that button in the published store view, including when it is focused and hovered at the same time.

Kowal Hyvä Colors · Publish a palette for a store view.

Previous Next

KOWAL.BLOG

Choose your language

Available versions open the corresponding page. More languages are being prepared.

English (UK) Français Deutsch Español Italiano Português Nederlands Svenska Dansk Norsk Suomi Lietuvių Latviešu Eesti Čeština Slovenčina Magyar Română Български Ελληνικά Slovenščina Hrvatski Polski English (US)