Write an adapter by hand
For people who code. Redbird turns off the keyboard focus outline, so when you press Tab you can't see where you are. In this guide, you write an adapter that puts it back, right in the browser.
See the issue
- Open the store with only issue 20 turned on (opens in a new tab).
- Click the search box, then press Tab a few times. The focus moves to the next link or button each time, but nothing on screen shows where it is. If you use a keyboard instead of a mouse, you can't tell which link or button you're on.
The four parts of an adapter
Every adapter is an object with four parts:
enabled: whether it's runningenable(options): changes the page.options.profileis the profile, if there is one.disable(): puts the page back exactly how it wastoggle(): switches between the two. The template's version works as it is.
Write the adapter
- Open the store with issue 20 and your adapter on (opens in a new tab). In the panel, open the Build your adapter tab. Under Your adapter, open The code. If you haven't made an adapter yet, it has a template in it.
- Replace everything in the code box with this code.
enable()adds a style rule that draws a blue outline around whatever has the focus, anddisable()removes it.JavaScript// Focus Ring: puts back a thick outline around whatever has the keyboard focus. export const FocusRing = { enabled: false, style: null, enable(options = {}) { if (this.enabled) return; this.enabled = true; // The store turns the outline off with an !important rule. This rule is just as // specific and comes later on the page, so it wins. this.style = document.createElement('style'); this.style.textContent = 'html.ws-focus-ring *:focus-visible { outline: 3px solid #0b6e99 !important; outline-offset: 2px !important; }'; document.head.appendChild(this.style); document.documentElement.classList.add('ws-focus-ring'); }, disable() { if (!this.enabled) return; this.enabled = false; this.style.remove(); document.documentElement.classList.remove('ws-focus-ring'); }, toggle(options) { if (this.enabled) this.disable(); else this.enable(options); }, }; - Click Save and run.
Check that it works
- Click the search box and press Tab a few times. A thick blue outline now moves with the focus.
- In the panel's Adapter Library tab, turn off your adapter. The outline goes away.
Tip
If your adapter has an error, the Build your adapter tab shows it under Your adapter. The most common one is a missing comma or bracket. You can also press Ask the AI to fix it.
Read the profile
Sam's profile has "vision" in supportAreas. Sam is blind and won't see the outline, but "vision" also covers people with low vision, who rely on a thick one. Make the outline twice as thick for anyone with "vision".
- In the code box, find these two lines:
JavaScript
this.style.textContent = 'html.ws-focus-ring *:focus-visible { outline: 3px solid #0b6e99 !important; outline-offset: 2px !important; }'; - Replace them with these three lines:
JavaScript
const width = options.profile?.supportAreas?.includes('vision') ? 6 : 3; this.style.textContent = `html.ws-focus-ring *:focus-visible { outline: ${width}px solid #0b6e99 !important; outline-offset: 2px !important; }`; - Click Save and run.
- Open the store as Sam (opens in a new tab). The outline is now twice as thick. With no profile (opens in a new tab), it's back to normal.
Keep your adapter
The code box only saves in this browser. To keep it, copy the code into a file of your own. Adapters here have the same four parts as the ones in the AI for Accessibility Toolkit, so yours can also go into the toolkit's tools/adapters/ folder.