Form
Form state and validation wired to the fields.
In Brand expressive
See it live
npm run storybookWhen to use it
In Brand expressive: The sign-up email, checked, with its error next to the field. Not for sections without a field.
- Use it when: Any form that checks answers and shows errors next to the fields.
- Not when: A single control that saves at once (a switch).
Instead:
- Field: How one control is laid out.
How Brand expressive uses it
Words
- Headlines are short and bold. Three to six words.
- Verbs that move: Join, Try, Go.
- Playful in headlines, plain in errors.
- Use: Join, Drop, Go, Love. Avoid: Synergy, Leverage, Kindly.
The labels components use, from the voice tokens:
content.action.commit: Gocontent.action.cancel: Not nowcontent.action.destroy: Removecontent.action.retry: Try againcontent.action.empty-action: Explore the drop
See Voice and tone for the whole voice.
Accessibility and keyboard
Test before you ship:
- Errors are announced, linked to their fields, and the first one gets focus on submit. undefined
Use it in code
npx open-ds add form
The component reads only component keys and semantic tokens, so it follows the brand and mode on <html>.
Tokens it reads
Form reads 6 tokens of its own, each an alias of a semantic token. Each row is one part: its own token, the semantic it aliases, and the value it ends at. Change a semantic and every component that reads it follows; override one of Form's tokens to change Form alone.
Brand expressive decides what changes when you switch theme. Here a switch changes colors only, so the marked rows differ between light and dark; everything else holds steady.
| Part | Its token and the semantic it aliases | Value |
|---|---|---|
| Item | ||
| Gap | component.form.item.gapspace.gap.defaultvar(--form-item-gap) | space.16:1rem |
| Text | ||
| Text Changes with theme | component.form.label.labelcolor.status.dangervar(--form-label-label) | Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B |
| Description | ||
| Text size | component.form.description.font-sizetype.body.font-sizevar(--form-description-font-size) | font.size.17:1.0625rem |
| Text Changes with theme | component.form.description.labelcolor.text.mutedvar(--form-description-label) | Lighttaupe.light.600:#6B544ADarktaupe.dark.400:#B5988A |
| Message | ||
| Text size | component.form.message.font-sizetype.body.font-sizevar(--form-message-font-size) | font.size.17:1.0625rem |
| Text Changes with theme | component.form.message.labelcolor.status.dangervar(--form-message-label) | Lightred.light.600:#C42B2BDarkred.dark.600:#F28B8B |