No.267 · Forms
Sentence Settings
Notification preferences written as the sentence they mean. Each underlined word is the current choice; press it and the alternatives open on a hairline under the word. The sentence rewrites itself to stay grammatical, and the only motion is a word changing.
The prompt
The design brief behind this component — reuse it to regenerate, remix, or explain it.
Build a settings form that is one paragraph of prose. <SentenceSettings fields value onChange sentence theme motion />. fields maps each id to { label, options: [{ value, label }] }. sentence(value, slot) returns the paragraph as JSX and calls slot(id) wherever a choice belongs, so the caller controls the grammar: for example, choosing 'daily' drops 'on Sunday', choosing 'no' summary drops the time, and choosing 'nothing' drops 'by push' and the quiet hours clause. Set the paragraph in a serif at clamp(1.35rem, 3.6vw, 1.85rem) with 1.55 line-height. Every slot is an inline button showing the current choice, underlined with a dotted 1.5px muted underline that becomes solid ink on hover or while open. It has aria-haspopup=listbox, aria-expanded, aria-controls and an aria-label of 'Field: Value'. Opening a slot places a small listbox (a span with role=listbox holding role=option spans, since it lives inside a paragraph) absolutely under the word: 1px ring, no blur, no heavy shadow, the sans face, the selected option in ink with a small accent bullet. Focus goes to the selected option. ↑/↓/Home/End move, Enter or Space chooses, Escape or Tab closes, and focus returns to the word. Choosing calls onChange({...value, [id]: option}). The only animation is a 140ms opacity fade on a word that has just changed (keyed by its value) and a 120ms fade on the listbox. A visually hidden polite live region repeats the full sentence's text whenever the value changes. Paper and Night themes; reduced motion removes both fades.
Notes
- Interaction
- Press any underlined word and choose. Change 'weekly' to 'daily' and 'on Sunday' disappears; choose 'nothing' and the rest of the sentence folds away.
- Motion
- A 140ms fade on the word that changed. Nothing else moves.
- Accessibility
- Each choice is a button with a listbox popup, labelled 'Field: Value'. Arrow keys, Home, End, Enter, Space, Escape and Tab behave as in a select; focus returns to the word. A polite live region announces the whole rewritten sentence after each change.
- Responsive
- It is prose: it wraps. The listbox is clamped to the viewport under 420px.