Forms and input actions
Native form controls, visible labels, inline fields, and input actions.
Form elements
Accessibility: Prefer native visible associated labels for ordinary controls, connect hints/errors with aria-describedby, and preserve native validation. The compact exception requires persistent visible context for each control. WAI forms guidance.
Submit is prevented in this non-networked example. Cancel is intentionally inert; Reset restores the initial values.
Placeholder text · dark
Inline forms and input actions
Accessibility: Keep this ordinary inline-field pattern’s labels visible, and use one naming source for each X. Prefer a concise aria-label for icon-only actions; valid hidden text remains supported. Synchronize clear visibility and move focus to the input before hiding the control. WAI label guidance.
Use an inline-field wrapper for a visible standard-size, medium-weight label above an input-row. The input grows; Add wraps to the right when space runs out. An optional input-action groups a text input with its X. Ordinary stacked forms keep their existing appearance.
The X is our shared close/clear icon action: a native button with data-barba-variant and data-barba-shape. It has a generous target, transparent resting face, a circular hover background inset by 2px, and a separate keyboard-focus outline. Disabled X actions use muted gray, retain the disabled opacity, and have no hover background. Its accessible name describes the action: “Clear item name” for an input, “Close dialog” for a modal. The icon is decorative; these actions do not delete saved data.
Input and Add
Add validates and reports locally; no information is saved or sent.
Input with an X
Only show the X when there is content. Keep its space reserved, and return focus to the input before hiding it. Applications handle clearing and synchronize visibility after typing, resets and programmatic value changes.
Initially empty
Controls associated with a separate form
Use the form attribute on both the input and its submit button. The label and row layout are identical.
Nothing added yet.
Outside a form
A standalone field can use the same input-action layout without a submit button.
Unavailable actions
For disabled or read-only inputs, a populated field retains a muted gray, disabled X instead of the enabled action color. It cannot change the value and has no hover background.
See the dialog examples for the same X button used to close a modal through its cancellation path.
Full markup, options, and customization reference
Input suggestion panels
This opt-in panel has no visible title. Its listbox has the accessible name “Destinations”. Focus the input to filter, then use ArrowDown or ArrowUp to inspect the active row while focus remains on the input. Type an unmatched value to see the empty result. Disabled rows remain unavailable.
Type to filter. Use arrow keys and Enter to choose, or Escape to dismiss.
No destinations available.
The example keeps the panel in normal flow. Applications own placement, scrolling, open/close state, matching, keyboard and pointer handling, input guards, active-descendant state, and announcements. This page's demonstration JavaScript is not shipped in the package. The component appearance requires only library CSS.
Use .suggestion-panel > ul[role="listbox"], presentation list items, and native button.suggestion-option[role="option"] rows. Add .suggestion-secondary for optional supporting text, and a sibling p.suggestion-empty outside the listbox for no results. Keep option buttons at tabindex="-1" when the input owns focus. Supply unique IDs, an accessible listbox name, and synchronized input ARIA state.
Compiled-package example · Full markup and ownership reference
Compact controls in persistent context
Keep visible native labels as the default. A compact control may use a concise aria-label when persistent surrounding content makes its purpose visually clear, even after typing or changing the selection. A generic “Categories” title alone does not explain every control. Here, the title and visible instruction together identify the quick-add dropdown and new-category input.
When suitable visible text already supplies the name and the relationship is clear, use aria-labelledby to reference it; prefer a native label when one fits. ARIA naming can override native or descendant text. Avoid redundant or competing names, and keep names synchronized with visible wording and translations.
Preserve visible identifying wording in the name, preferably at the beginning: “Create” becomes “Create category”, and the input retains “Category name”. A placeholder alone is insufficient because it disappears. The dropdown’s stable name identifies its purpose; the browser separately exposes the selected option.
Copyable markup, not a working editor: this example uses existing disclosure and input-row classes. The inline-field wrapper above keeps its visible-label convention. Use unique IDs for each instance; adapt the context, names, placeholder, and references together for Stores or other editors.
<details class="disclosure" open>
<summary>
<span class="disclosure-label disclosure-title">Categories</span>
</summary>
<div class="disclosure-content">
<p id="category-help">Quick add an existing category, or enter a category
name and choose Create.</p>
<select aria-label="Quick add an existing category"
aria-describedby="category-help">
<option value="">Quick add</option>
<option value="produce">Produce</option>
<option value="frozen" disabled>Frozen — selected</option>
</select>
<div class="input-row">
<input id="new-category" type="text" aria-label="Category name"
placeholder="Category name" aria-describedby="category-help">
<button type="button" aria-label="Create category">Create</button>
</div>
</div>
</details>
Application code owns dropdown selection/reset, disabled choices, Create/Enter behavior, validation, focus, and announcement timing. type="button" does not submit or implement Enter-to-create. Choose form ownership and handlers deliberately; CSS supplies none of that logic.
Associate useful instructions and errors with aria-describedby, and retain validation/error associations. Keep necessary instructions visible; additional draft/Save detail can live in the application’s help disclosure. Avoid repetitive explanations of native dropdown operation.
Keep status updates separate from names. Changing aria-label does not announce a result. Prefer an existing visible status message, or use one persistent, initially empty status region before updates; avoid duplicate announcements. Existing valid hidden labels do not need automatic migration. See naming choices, status examples, and W3C form-label guidance.