Alt Text Check

Checks each image's alt text before posting, so filenames, "image of" and empty alt text don't reach screen-reader users.

StopsUnusable alt text gets posted

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/alt-text-check.json

The files land in your project. They're yours to edit.

Usage

alt-text-check-usage.tsx
import { AltTextCheck, type AltImage } from "@/components/ui/alt-text-check"

<AltTextCheck defaultValue={images} onPost={() => setPosted(true)} />

What it catches

  • Missing alt text
  • Filenames, camera names and hashes used as alt text
  • "Image of" / "picture of" redundancy
  • Alt text that repeats the caption, or runs past the length limit
  • Screenshots and images with text whose alt text may not include that text

Props

AltTextCheck props
PropTypeDefault
value

Controlled images.

AltImage[]—
defaultValue

Initial images when uncontrolled.

AltImage[][]
onValueChange

Called with the updated images whenever alt text or the decorative flag changes.

(images: AltImage[]) => void—
onPost

Called when posting. With problems left, the first click jumps to them and asks again.

(images: AltImage[]) => void—
maxLength

Alt text longer than this is flagged.

number125
chipLabels

Status chip labels, by status.

Partial<Record<AltStatus, string>>—
summaryText

`{count}` (images with problems) and `{total}` are filled in. Without `{total}`, `{count}` reads "3 of 4".

string"{count} of {total} need better alt text"
messages

Reasons shown under each flagged image.

Partial<typeof ALT_TEXT_MESSAGES>—
allGoodText

Summary shown when every image passes.

string"Every image is described"
altLabel

Label for each alt text field.

string"Alt text"
decorativeLabel

Label for the decorative toggle.

string"Decorative"
textHint

Reminder shown for images that contain text.

string"Has text in it? Include the words that matter."
decorativePlaceholder

Placeholder shown in the field when the image is marked decorative.

string"Skipped by screen readers (alt=\"\")"
fixLabel

Text for the one-tap fix button.

string"Remove “Image of”"
clearLabel

Text for the button that clears a filename used as alt text.

string"Clear it"
postLabel

Post button text.

string"Post"
postAnywayLabel

Post button text after problems were shown once.

string"Post anyway"

* required. Also accepts the native props of <div> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Each alt field has a <label> and aria-describedby pointing at its hint; aria-invalid when there is a problem
  • Per-image hints and the summary are aria-live="polite"
  • Post moves focus to the first field with a problem
  • Status uses text and icons, not colour alone

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

  • It checks wording patterns, not whether the description is accurate
  • Whether an image contains text comes from your data (OCR or uploader); screenshots are assumed to
  • Posting with problems is still possible after the first press

What it stops

Unusable alt text gets posted

Also known as

alt text · accessibility · a11y · image upload · screen reader · wcag · post composer · cms

Field type

Dependencies

Pairs well with