Skip to main content

Select

A common form component for choosing a predefined value in a dropdown menu.

Features

Installation

typo3 ui:add select

Read more about installing Components and Primitives.

Examples

Default Value

Set an initial selected value.

Multiple Selection

Allow selecting multiple items.

Disabled Items

Disable specific items in the list.

With Item Groups

Organize items into logical groups.

With Form Field

Use with the Field component for form validation.

Localization

Default clear trigger labels are shipped via XLF and follow the current Site Language. For per-template overrides, pass translated strings through the translations prop. Set clearTriggerLabel to {false} or an empty string to omit the aria-label.

<ui:select.root
    collection="{myCollection}"
    translations="{
        clearTriggerLabel: f:translate(key: 'LLL:EXT:site_package/Resources/Private/Language/locallang.xlf:select.clear')
    }"
>
    ...
</ui:select.root>

API Reference

The following tables cover the available props of the Fluid Primitives. For a full list of available client side props and methods, see the Zag.js Machine API.

select.root

Provides shared select state and wraps all related parts. Renders a <div> element.

NameDescriptionRequiredDefault
collectionDomain\Model\ListCollection
The item collection.
Yes
-
namestring
The `name` attribute of the underlying select. Inherited from a surrounding field when available.
No
-
formstring
The associate form of the underlying select.
No
-
disabledboolean
Whether the select is disabled. Inherited from a surrounding field when available.
No
-
invalidboolean
Whether the select is invalid. Inherited from a surrounding field when available.
No
-
readOnlyboolean
Whether the select is read-only. Inherited from a surrounding field when available.
No
-
requiredboolean
Whether the select is required. Inherited from a surrounding field when available.
No
-
closeOnSelectboolean
Whether the select should close after an item is selected.
No
true
positioningarray
The positioning options of the menu.
No
{
    "placement": "bottom-start",
    "gutter": 8
}
defaultValuemixed
The initial default value of the select when rendered. Use when you don't need to control the value of the select. Inherited from a surrounding field when available.
No
-
defaultHighlightedValuestring
The initial value of the highlighted item when opened. Use when you don't need to control the highlighted value of the select.
No
-
loopFocusboolean
Whether to loop the keyboard navigation through the options.
No
false
multipleboolean
Whether to allow multiple selection.
No
-
defaultOpenboolean
Whether the select's open state is controlled by the user.
No
-
compositeboolean
Whether the select is composed with other composite widgets like tabs or combobox.
No
true
deselectableboolean
Whether the value can be cleared by clicking the selected item.
No
-
translationsarray
Localized select labels. Set entries to `` to omit the corresponding `aria-label`. Use `f:translate` for per-template localization overrides when needed.
No
-

select.label

Labels the select. Renders a <label> element.

select.control

Groups the trigger and optional clear button. Renders a <div> element.

select.trigger

Opens and closes the select menu. Renders a <button> element.

select.valueText

Displays the selected value or placeholder text. Renders a <span> element.

NameDescriptionRequiredDefault
placeholderstring
The placeholder text to render when no value is selected.
No
-

select.indicator

Displays a decorative indicator for the trigger. Renders a <span> element.

select.clearTrigger

Clears the current selection. Renders a <button> element.

select.positioner

Positions the floating select content. Renders a <div> element.

select.content

Contains the selectable options. Renders a <div> element.

select.itemGroup

Groups related options together. Renders a <div> element.

select.itemGroupLabel

Labels a group of related options. Renders a <div> element.

select.item

Represents a selectable option. Renders a <div> element.

NameDescriptionRequiredDefault
itemmixed
The item to render.
Yes
-

select.itemText

Displays the text content of an option. Renders a <span> element.

select.itemIndicator

Displays the selected-state indicator for an option. Renders a <div> element.

select.hiddenSelect

Provides the native <select> element for form submission. Renders a <select> element.

Anatomy

<primitives:select.root>
    <primitives:select.label />
    <primitives:select.control>
        <primitives:select.trigger>
            <primitives:select.valueText />
            <primitives:select.indicator />
        </primitives:select.trigger>
        <primitives:select.clearTrigger />
    </primitives:select.control>
    <primitives:select.positioner>
        <primitives:select.content>
            <primitives:select.item>
                <primitives:select.itemText />
                <primitives:select.itemIndicator />
            </primitives:select.item>
            <primitives:select.itemGroup>
                <primitives:select.itemGroupLabel />
            </primitives:select.itemGroup>
        </primitives:select.content>
    </primitives:select.positioner>
    <primitives:select.hiddenSelect />
</primitives:select.root>