IDs to add to the inner control's aria-describedby: the hint, then the shown message.
checkValidity()
True when the value is valid; otherwise fires invalid and returns false, like native.
reportValidity()
Like checkValidity(), and also shows the browser's validation message when invalid.
setCustomValidity(message)
Set (non-empty) or clear (empty string) a custom validation error, like native controls.
setValidityState(flags, message, anchor)
For subclasses: set the validity flags and message. anchor is the element the browser points its message at.
validate()
Show (or clear) the error from the control's own checks: required, type, pattern, min,
max and the like. Uses error-message, else the browser's localized message. An error the
author set (a server error, say) is left as it is.
clearValidation()
Clear the error and warning that validate() and warning-pattern showed (a form reset does).
emitValue(commit)
For subclasses: fire the value events, as a native control does on a user edit: input
(bubbles, composed), then with commit also change (bubbles, stays in its tree).
idrefText(ids)
For subclasses: the text of the elements an ID reference list names, resolved in the host's
tree (ID references cannot cross a shadow root), joined by spaces.
Events
Event
Description
input
Fired on every user change of the selection.
change
Fired with input when the user changes the selection.
Slots
Slot
Description
(default)
The focsd-option and focsd-option-group children (data; not rendered themselves).
CSS parts
Style the inside of the component with ::part(), for example focsd-listbox::part(layout).
Part
Description
layout
The wrapper holding the label and the body; its `data-position` is the label position.
body
The listbox, then the hint and the message.
label
The label element.
listbox
The `role="listbox"` box that takes focus.
option
One option row; also `active` for the active option and `selected` when chosen.
active
The active option row.
selected
A selected option row.
group
A group of options.
group-label
A group's visible label (the group is named by `aria-label`).
check
The check mark of a selected option (with `multiple`).
hint
The author's hint.
message
The shown error, warning or success message (also named by its kind).
message-icon
The icon in the message.
announcer
The live region that announces a changed message.
Accessibility
A labeled role="listbox" that takes focus itself; the active option is pointed to with aria-activedescendant, so screen readers read each option as the arrows move. Groups are named role="group"s.
With one value, the selection follows the active option, as in a native list box. With multiple, the list is aria-multiselectable and moving never changes the selection on its own: Space does.
Disabled options are announced as unavailable and skipped by the arrows and by typing. The arrows stop at the first and last option instead of wrapping.
Listbox or list? Use focsd-listbox for a form value that should always be on screen: it is form-associated and submits one entry per selected value. Use focsd-list with selectable for navigation-style choice, such as picking which message to read.
Options are data: each row shows the option's label (or its text), not rich content such as icons or markup inside the focsd-option. Set the selection with the listbox's value or values; writing option.selected from code does not change it (the selected attribute sets the default). Give each option its value as an attribute: a value set only as a property on a focsd-option is not picked up until the options change again.
Form-associated: participates in FormData, required validation, reset (back to the value attribute or the options marked selected), fieldset disabled and back/forward restore.
Keyboard
Key
Action
Arrow Down / Up
Next / previous option (Right / Left with orientation="horizontal")
Home / End
First / last option
Letters
Next option starting with the letters typed; type quickly to search several
Space
Select or clear the active option (multiple)
Shift + Arrow
Select from the last chosen option to the next one; moving back deselects (multiple)
Shift + Space
Select every option from the last chosen one to the active one (multiple)
Ctrl / ⌘ + A
Select every option, or none when all are selected (multiple)
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.