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!

Buttons

Example 1 - no border, adding dark outline

No visible border, adding a dark outline on focus.

Example 2 - dark border, dark outline

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

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 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:

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.



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.