Focus visible - testing adjacent vs change methods

A few examples of focus styles, highlighting the difference between 'adjacent' methods and 'change' methods.

Multiple button in each are used so you get an idea of what it's like when tabbing through a real interface.

Black/white/grey is used to make these example extreme to test the logic. Using colors of various hues would make the indicators easier to see (with regular vision), but we want a difficult test!

The different methods of testing are for:

Buttons

Example 1 - no border, adding dark outline

No visible border, adding a dark outline on focus.

Example 1b - no border, adding dark outline on a dark background

Same as example 1 but focus style of #333 on a dark background of #7c7c7c that is 3:1.

Same results as 1, but showing the difference a dark background makes so the outline color is at minimim contrast with the background.

Example 1c - no border, adding minimal dark outline

No visible border, adding a dark outline on focus that just meets 3:1 with white.

Same as example 1 (passing), but at the minumum threshhold.

Example 2 - dark border, dark outline

Dark border, adding a dark outline on focus, which basically doubles the thickness:

Example 2b - dark border minimum

Dark border, adding a minimum contrast dark outline (#949494 with 3:1 against white) on focus:

Same results as example 2, but just showing what the minumum would look like.

Example 2c - dark border minimum

Dark border, adding a minimum contrast dark outline (#949494 with 3:1 against white) on focus:

Same results as example 2, but just showing what the minumum would look like.

Example 3 - dark border, light outline

Dark border, light (#ccc) outline on focus:

Example 4 - Outset

Dark border, dark outline fully outside the button using outline-offset: 2px:

Passes all.

NB: Same results for 'inset' as well.

Example 4b - Outset minimum

Dark border, dark outline fully outside the button using outline-offset: 2px, but using #949494 with 3:1 against white:

Same results example 4, just showing the minumum contrast.

Example 5 - Invert colours

Foreground and background colour inversion:

Example 6 - Invert colours plus border

Foreground and background colour inversion, with initial border:

Example 7 - CurrentColor light background

Using the currentColor keyword in CSS so the outline has the same color as the text:

Passes all, same as example 1.

Example 8 - CurrentColor dark background

Same as example 7, but inverting the foreground/background color, so the white text (and therefore white outline) is invisible against the background:

Example 9 - Dark component with minimal outline added

Dark component, focus is a 1px grey outline (3:1 with white) outset by 1px:

Same as example 4 but dark component and minimal outset outline used.

Example 9b - Dark component with 2px dark outline

Dark component, focus is 2px outline matching the component color:

Same as example 9 but 2px border used instead of outset (to pass current SC text).

Inputs

Inputs do need a visual indicator, such as a border, so there are fewer options compared to buttons.

Example 10 - Black outline

Increasing the default contrast of the border (to pass non-text contrast), and adding a 1px dark outline on focus.



Example 11 - Dark background and light outline

Creating an extreme black/white/grey version of the Gov.uk search box, the following inputs have a 2px light-grey outline on focus.



Example 11b - Dark background and yellow outline

Creating a less extreme version of example 11.



(Same results as 11.)

Example 12 - Dark background - inset light outline

Creating an extreme black/white/grey version of the Gov.uk search box, the following inputs have a 2px light-grey outline on focus.



Example 13 - Outline contrasts with both

Aiming to have a middle grey that contrasts with both the background and component. It works, but there is a super-narrow range of colors that this works for.



Passes all, being 2px and contrasting with both the component and background.

Example 14 - comparing outlines around borders

Three examples showing a 1px outline, a 2px outline, 1px outset by 1px, and 1px outset by 2px.

The first would fail the draft SC due to being 1px wide and adjacent to the dark border, the others would pass.

Example 15 - comparing sizes of indicator

Four examples showing a 1px outline, a 1px bottom-only outline, 2px extra bottom border, and 5px left border.

All of these pass the draft SC text.

Example 16 - plain text links

Link 1 Link 2 Link 3 Link 4