Inputs
Fields, choices, filters, combobox, tag input, secret field, schedule and the error summary.
Fields
A visible label before every control, a hint under the label when needed, and an error that says how to fix it.
Rules
- No placeholder as a label. Placeholders only show an example.
- Errors appear on leaving the field or on save, never while the person is still entering text; focus moves to the first error on save.
- Units sit beside the box, not in the label.
Classes
.field,.hint,.field-error(also written.field__error),.input,.select,.textarea,.input-group,.form-grid.input--narrow: a number field about eight characters wide, so a count does not stretch across the row..select--compact: a select at the compact control height (32px), for a dense toolbar or a card's tools.
File picker
From the plug-in's own page.
Checkboxes, switches and choices
Checkboxes for things saved with a Save button; switches for things that apply at once; segmented controls for two to five short options; option cards when each option needs a line of explanation.
Sortable list
Rows in an order the person chooses, such as qualities best first. Move up and Move down on every row work with a keyboard, a screen reader and on a phone; the handle drags with a mouse or a finger. A marker row, such as Stop upgrading here, moves the same way. Each move says where the row is now and sends a sortable-change event with the new order.
- 2160p Blu-ray
- 2160p web
- Stop upgrading here
- 1080p Blu-ray
- 1080p web
- 720p web
Filter chips and applied filters
Filter chips are buttons in a toolbar that are pressed or not (aria-pressed). Applied filters show what is in use, each with a remove button, and a Clear all.
Rules
- Every filter and sort starts from the current address, so two changes in a row both stick.
- Filters are in the address, so Back and shared links keep them.
Combobox (searchable select)
A box that narrows a long list as you enter text, then you choose one. The matching part of each name is underlined, and "No languages match" shows when nothing does.
Enter part of the name, then choose it from the list.
- Arabic
- Chinese
- Danish
- Dutch
- English
- French
- German
- Hindi
- Irish
- Italian
- Japanese
- Korean
- Norwegian
- Polish
- Portuguese
- Scottish Gaelic
- Spanish
- Swedish
- Turkish
- Ukrainian
- Welsh
When to use it
- Choosing one from more than about 15 options, such as a language, a time zone or a folder on a list.
- Where people know the name they want.
When not to
- Fewer than about 15 options: use a select or radios.
- More than one choice: use filter chips or checkboxes.
- Free text with suggestions only: use a plain text box.
Accessibility
- ARIA 1.2 combobox with a listbox. Focus stays in the box;
aria-activedescendantpoints at the option the arrow keys reach, which has the focus ring. - Down opens the list, Up and Down move, Enter chooses, Escape closes the list and then clears the box, Tab leaves.
- The number found is said politely after a pause; leaving the box keeps an exact name, or goes back to the last choice.
Classes and behaviour
.combobox[data-combobox]withdata-nounanddata-noun-one;__input,__toggle,__popup,__list,__option,__hint,__none, and a hidden input for the value.SharedComponents.combobox(box, {{ options, onChoose, always }})returnssetOptions; thecombobox-changeevent.
Tag input
A list of short words entered one at a time: Enter or a comma adds each, and each has its own Remove button. Pasting "cam, ts, hdcam" adds all three.
Releases with any of these words in their name are skipped. Press Enter or a comma after each one.
- cam
- telesync
When to use it
- A handful of short free words or names: words to skip, tags, extra addresses.
- When the order does not matter.
When not to
- Choosing from a known list: use the combobox or checkboxes.
- Long values or an order that matters: use rows with a sortable list.
Accessibility
- A real text box with a label and hint; the words are a list named like the field.
- Each Remove button is named with its word ("Remove cam"). Adding and removing are said politely; a word already in the list says so.
- After a removal, focus moves to the next Remove button or back to the box; Backspace in an empty box moves to the last one.
Classes and behaviour
.tag-input[data-tag-input],__list,__tag,__field, and a hidden input with the words joined by commas.- The
tags-changeevent with{{ values }}.
Secret field
An API key, token or password that the app keeps: hidden until Show, with Copy and Replace beside it. Replace empties the box for the new one, with Save and Cancel.
Starboard uses it to ask Jellyfin what is playing. Replace it when you make a new key in Jellyfin.
When to use it
- A key, token or password that is saved and people may need to read, copy or change.
- In a settings section or an app's slide-out.
When not to
- Signing in: use a password field with
autocomplete="current-password". - A key the server must never send back: show "Saved" and Replace only.
Accessibility
- Show and Hide are one button with
aria-pressed, named with the thing ("Show API key"); the change is said politely. - Copy confirms in a toast that never holds the value. Replace moves focus into the empty box and says what to do; Enter saves and Escape cancels.
- The value is never in an attribute, a message, the page title or the console.
Classes and behaviour
.secret-field[data-secret][data-name],__input,[data-secret-show],[data-secret-copy],[data-secret-replace].- The
secret-changeevent with{{ value }}for the app to save; set the value withinput.value, never in the markup.
Schedule picker
How often, on which days and at what time, read back in words and with the next time it runs.
When to use it
- Anything that runs by itself on a timetable: backups, checks, updates, searches.
- Where the times are the same each day or week.
When not to
- One date and time: use a date and a time field.
- A timetable people cannot change: say it in words, such as "Every day at 03:00".
Accessibility
- Real fields: a select, a time box and checkboxes in a fieldset named Days, each day's full name for screen readers.
- The words and the next time are a polite status, so a change is read back.
- Times use the 24-hour clock (CONTENT-DESIGN.md section 3).
Classes and behaviour
.schedule[data-schedule],__row,__days,__day,__words;[data-schedule-repeat],-time,-minute,-days,-words,-next.SharedComponents.scheduleWords(value),nextRun(value)and theschedule-changeevent.
Error summary
After GOV.UK. When a form is sent with mistakes, a summary at the top lists each one as a link to its field, and focus moves to it. Each field still shows its own error. Select Save server with the fields empty, or with a port of 70000.
When to use it
- Every form with more than one field that is checked when it is sent.
- With
.field-erroron each field, never instead of it.
When not to
- A single field that checks itself as it saves (
.inline-save): its own error is enough. - Problems that are not about a field: use a danger notice.
Accessibility
- Focus moves to the summary, which is read at once; "Error: " goes at the start of the page title.
- Each link names the problem in the field's own error words, and moves focus to the field with its label in view.
- Each field has
aria-invalidand its error tied byaria-describedby, with "Error: " in hidden text.
Classes and behaviour
.error-summary,__title,__list, with.field-error.SharedComponents.showErrors(form, [{{ field, message }}]),clearErrors(form)andsetFieldError(control, message).