Accessibility

Fern supports accessibility standards out of the box.

Reach for it when
  • Before shipping any control, list, dialog or animation.
  • When choosing a text token for a surface, check the live contrast table.

The short version

If you read nothing else on this page, read these.

LivePublishingError
Do. Pair every status hue with a label or an icon.
docs.acme.devdocs.acme.devdocs.acme.dev
Don't. Carry status by color alone. About 1 in 12 men can't tell these dots apart.
Do. Keep row actions at 32px, 8px apart, with a name for screen readers.
Don't. Shrink a control to fit a dense row. Pad the row, never the target.

Contrast

Every text token is checked on the surface it's meant for. Body text needs 4.5:1; large text, icons and redundant meta text need 3:1.

Contrast checker

Choose a text token and a surface. Translucent fills are flattened onto the page first.

on
light
Your site is liveVisitors can read docs.acme.dev from anywhere.
5.92:1Large textAAAAA
dark
Your site is liveVisitors can read docs.acme.dev from anywhere.
8.89:1Large textAAAAA
Text on surfaceRoleNeedsLightDark
text-foreground on bg-backgroundBody text4.5:1
16.29
15.88
text-muted-foreground on bg-backgroundSecondary text4.5:1
5.92
8.89
text-subtle-foreground on bg-backgroundPlaceholders, meta (large or redundant)3:1
5.92
8.89
text-primary on bg-backgroundLinks, active icons4.5:1
4.70
11.04
text-card-foreground on bg-cardText on cards4.5:1
16.29
15.88
text-popover-foreground on bg-popoverMenu items4.5:1
16.29
15.15
text-foreground on bg-accentHovered rows and items4.5:1
14.30
13.21
text-primary-foreground on bg-primaryText on the brand fill4.5:1
4.51
11.87
text-danger on bg-backgroundError text4.5:1
5.21
7.45
text-danger on bg-danger-surfaceError text in a Note4.5:1
4.94
7.32
text-warning on bg-warning-surfaceWarning text in a Note4.5:1
4.43
11.52
text-success on bg-success-surfaceSuccess text in a Note4.5:1
4.49
10.61
text-info on bg-info-surfaceInfo text in a Note4.5:1
4.53
8.38

Focus

One ring for every control, visible whenever the keyboard is in use.

Try it

Click a control, then press Tab and Shift+Tab. The ring shows for the keyboard, not the mouse.

Pinned on

border-focus plus a 3px ring-focus/50, the same on every control.

Targets

Dense rows pad the hit area; they don't shrink the control.

Hit areas

32px minimum, never narrower than square, 8px between neighbours.

32 × 32
32 × 32
36 × 36
32 × 54

Rules

Every rule on one list. Open one for the reasoning behind it.

8 rules
  1. 01Contrast is checked against the surface the text sits onBody and label text meet WCAG AA (4.5:1). Large text and icons meet 3:1. Subtle text is reserved for placeholders, timestamps and counts, where the primary value is also shown another way.
  2. 02Everything works from the keyboardTab reaches every control in reading order. Enter and Space activate, Escape closes, arrows move within a list, menu or segmented control. Dialogs trap focus and return it to the trigger on close.
  3. 03Focus is visible and the same everywhereControls use the shared focus-visible ring (border-focus plus a 3px ring-focus/50). Never remove the outline without replacing it. Mouse clicks don't show the ring; keyboard focus always does.
  4. 04Targets are at least 32px, with 8px between themButtons are never narrower than square (min-w-* matches the height). Icon-only buttons use size="icon", iconSm or iconXs, which are exactly square (size-*, no min-w-*, so a size-* override in className resizes both sides), and dense rows add padding to the clickable area rather than shrinking it.
  5. 05Status is never carried by color aloneA status always has a label or an icon next to its hue: StatusBadge pairs the dot with text, Note pairs the tint with an icon, charts carry legends. Red, amber and green are reinforcement, not the message.
  6. 06Icon-only controls have an accessible nameEvery icon button gets aria-label. Decorative icons next to a label are aria-hidden. Tooltips repeat the label for sighted users and are never the only name.
  7. 07Motion has a reduced-motion stateUnder prefers-reduced-motion, transitions are shortened and non-essential movement stops. Each state (loading, selected, open) still reads without the animation.
  8. 08Live changes are announcedToasts, save confirmations and streaming text use aria-live="polite". Errors tied to a field set aria-invalid and aria-describedby to the message.

Keep going

Color
Semantically named colors and a set of ramps for the full palette. Optimized for light and dark.
Motion
Short, consistent motion that respects reduced motion.
Content
Write plainly with sentence case. Follow these guidelines to ensure you do so.