GridSelectGridSelect
Guide
Reference
Demo
npm
GitHub
Guide
Reference
Demo
npm
GitHub
  • Options
  • Attributes and hooks
  • Instance and events
  • CSS variables
  • Changelog
  • Contributing

Attributes and hooks

GridSelect is configured through attributes in three places: on the <grid-select> element, on the wrapper of a group set up with gridselect(), and on the elements GridSelect builds itself. This page lists all three. The last two lists are useful when you write your own CSS or automated tests, because these attributes are stable from version 1.0 on.

Attributes of <grid-select>

These attributes configure the custom element. Most of them correspond to an option of the same name, written in kebab-case.

AttributeMeaning
nameThe name under which a form submits the choice.
labelThe visible name of the group, shown as its legend. Without label or aria-label the console warns, because a group needs a name.
aria-labelA name for screen readers only, used when no visible label is wanted.
multipleAllows several choices; the element then works with checkboxes.
valueThe initial choice, comma-separated with multiple. Without it, the selected options decide.
required, disabledWork as on native form fields.
threshold, layout, search, match, placeholder, search-placeholderThe options of the same name.
shortcutsoff, or the tiers separated by commas, for example ,Shift,Alt.
max, search-description, panel-height, panel-width, panel-container, close-textThe options max, searchDescription, panelHeight, panelWidth, panelContainer and closeText.
sheetoff keeps the normal panel on phones, like the option sheet: false.
pinned, recent, recent-max, pinned-text, recent-textPinned and recent entries; pinned is a comma-separated list.
min-query-length, loading-text, error-textSettings for entries from a server. The function itself is set as the property el.load.

The element also has properties that cannot be expressed as attributes: el.value, el.items, el.load, and, because it is a form field of its own, el.form, el.name, el.validity, el.validationMessage, el.willValidate, checkValidity(), reportValidity() and setCustomValidity(). See Custom element and frameworks and Forms.

Data attributes on the wrapper

When you use gridselect(), you can write most options as data- attributes on the wrapper instead of passing them in JavaScript. This is convenient when the HTML comes from a server or a template. If an option is given both ways, the JavaScript option wins.

AttributeCorresponding option
data-thresholdthreshold
data-layoutlayout (grid, list or flow)
data-searchsearch (filter or highlight)
data-match-modematch (substring or fuzzy)
data-shortcuts="off"shortcuts: false
data-maxmax
data-pinned, data-recent, data-recent-maxpinned, recent, recentMax
data-search-descriptionsearchDescription
data-panel-width, data-panel-height, data-panel-containerpanelWidth, panelHeight, panelContainer
data-sheet="off"sheet: false

The container that data-panel-container names is marked with data-gridselect-container="<name>". This attribute goes on an element around the wrapper, such as a page column or a <form>, not on the wrapper itself; The panel explains how it works.

Structure hooks

Every element GridSelect builds carries a data-gridselect-* attribute and a CSS class of the same name in the BEM style (for example data-gridselect-field and gridselect__field). Use them to style the parts or to find them in tests.

HookElement
data-gridselectThe wrapper you write around the group.
data-gridselect-fieldThe button above the threshold that shows the choice and opens the panel.
data-gridselect-panelThe panel. It carries data-placement="top" when it opens upwards and data-sheet when it opens as a full-screen sheet on a phone.
data-gridselect-head, data-gridselect-title, data-gridselect-closeThe row above the search on touch screens, the group's name in it (phones only) and the close button.
data-gridselect-searchThe search input, announced as a combobox.
data-gridselect-scrollerThe scrolling area of the panel, announced as a listbox.
data-gridselect-itemsThe list of items inside the scrolling area.
data-gridselect-itemOne item in the panel, announced as an option, with its value in data-value.
data-gridselect-labelThe text of an item.
data-gridselect-descriptionThe second line of an item, see Descriptions.
data-gridselect-keyThe digit badge. data-modifiers holds the tier's modifier keys, data-prefix the letters shown before the digit.
data-gridselect-group, data-gridselect-group-labelA group of items and its heading, see Groups.
data-gridselect-top, data-gridselect-sectionThe pinned and recent groups at the top, and the rest of the list below them.
data-gridselect-emptyThe message in the panel, for example "No matches" or "Loading…".
data-gridselect-statusThe hidden status region that screen readers read out.
data-gridselect-generatedLabels that GridSelect created from items or from a <select>.

State attributes

GridSelect expresses states as attributes, mostly the standard ARIA attributes that screen readers also rely on. Style these instead of adding your own classes.

AttributeMeaning
aria-expanded="true"On the field and the search input while the panel is open.
aria-selected="true"On items that are chosen.
data-cursorOn the item under the cursor, the one the arrow keys point at.
data-match, data-dimmedIn highlight mode, on matching and on non-matching items.
aria-disabled="true"On disabled items. Together with data-limit it marks an item that is locked because a multiple choice reached its max.
aria-invalid="true"On the field (or the inputs below the threshold) after a submit was blocked because a required group was empty.
Edit this page
Last Updated: 11/10/26, 4:41 PM
Contributors: Michael Grossklos, Claude Opus 5.5