YAML Field

Catches YAML that parses but means something else, like NO read as false or 1.10 read as 1.1, and shows what the parser will read.

StopsYAML NO read as false

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/yaml-field.json

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

Usage

yaml-field-usage.tsx
import { YamlField } from "@/components/ui/yaml-field"

return <YamlField label="deploy.yaml" defaultValue={config} rows={7} className="max-w-sm" />

What it catches

  • Plain scalars YAML 1.1 loaders turn into booleans (NO, yes, on, off)
  • Version-like numbers that lose digits (1.10 → 1.1)
  • Leading-zero octals and base-60 times
  • Duplicate keys, with the first occurrence
  • Tabs and misaligned indentation

Props

YamlField props
PropTypeDefault
label

Visible label.

string"YAML"
hint

Helper text shown while the field is empty.

string—
value

Controlled value.

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the text on every change, including fixes.

(value: string) => void—
delay

Pause in ms before problems show while typing. Leaving the field shows them at once.

number600
maxShown

How many problems are listed at once.

number4
summary

Heading of the list; `{count}` is filled in.

string"{count} to check"
quoteAllLabel

Label of the button that quotes every value read as the wrong type; `{count}` is filled in.

string"Quote all {count}"
validMessage

Shown when nothing was found.

string"No YAML traps found"
fixLabels

Labels of the one-tap fixes, per mistake.

Partial<Record<YamlMistake, string>>—
firstLabel

Label of the button that jumps to the first copy of a duplicate key; `{line}` is filled in.

string"Go to line {line}"
moreLabel

Shown when more problems exist than `maxShown`; `{count}` is filled in.

string"+{count} more"

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

Accessibility

  • Visible <label>; status via aria-describedby in a polite live region
  • Each issue has a button labelled with its line and column
  • After a fix, focus returns to the textarea

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

Limitations

  • Targets YAML 1.1 behaviour (PyYAML, Psych, SnakeYAML, go-yaml v2); YAML 1.2 loaders differ
  • Not a full YAML parser; complex documents can produce misses

What it stops

YAML NO read as false

Also known as

yaml · yml · config · docker compose · github actions · kubernetes · helm · ci config

Field type

Dependencies

Pairs well with