Skip to main content

Select ready

Select lets user choose one option from an options menu. Consider using select when you have 4 or more options. Select component supports any content type.

Examples

Open in new window
<duet-select label="Kaupunki" placeholder="Valitse…" expand></duet-select>

<script>
// Save a reference to the above select component
var select = document.querySelector("duet-select")

// Set select menu items and their values
select.items = [
{ label: "Helsinki", value: "1" },
{ label: "Tampere", value: "2" },
{ label: "Vantaa", value: "3" },
{ label: "Espoo", value: "4" }
]

// Listen for change events in the select
select.addEventListener("duetChange", function(e) {
console.log("Change event detected in select:", e.detail)
})
</script>
Open in new window
<duet-select label="Kaupunki" placeholder="Valitse…" value="2" expand></duet-select>

<script>
var select = document.querySelector("duet-select");

select.items = [
{ label: "Helsinki", value: "1" },
{ label: "Tampere", value: "2" },
{ label: "Vantaa", value: "3" },
{ label: "Espoo", value: "4" }
];
</script>
Open in new window
<duet-select label="Kaupunki" placeholder="Valitse…" expand disabled></duet-select>

<script>
var select = document.querySelector("duet-select");

select.items = [
{ label: "Helsinki", value: "1" },
{ label: "Tampere", value: "2" },
{ label: "Vantaa", value: "3" },
{ label: "Espoo", value: "4" }
];
</script>

Properties #

Property Attribute Description Type Default
accessibleActiveDescendant accessible-active-descendant Indicates the id of a related component’s visually focused element. string undefined
accessibleControls accessible-controls Use this prop to add an aria-controls attribute. Use the attribute to indicate the id of a component controlled by this component. string undefined
accessibleOwns accessible-owns Indicates the id of a component owned by the select. string undefined
disabled disabled Makes the select component disabled. This prevents users from being able to interact with the select, and conveys its inactive state to assistive technologies. boolean false
error error Display the select in error state along with an error message. string ""
expand expand Expands the input to fill 100% of the container width. boolean false
identifier identifier Adds a unique identifier for the select. string undefined
items -- An array of items to choose from any[] undefined
label label Label for the select. string "label"
labelHidden label-hidden Visually hide the label, but still show it to screen readers. boolean false
margin margin Controls the margin of the component. Can be one of: "auto", "none". string "auto"
name name Name of the select. string undefined
placeholder placeholder Hint text to display. string ""
role role Defines a specific role attribute for the select. string undefined
theme theme Theme of the select. Can be one of: "default", "turva". string ""
tooltip tooltip Tooltip to display next to the label of the input. string ""
value value The selected value of the select string undefined

Events #

Event Description Type
duetBlur Emitted when the select loses focus. CustomEvent<any>
duetChange Callback for when the value changed. CustomEvent<any>
duetFocus Emitted when the select has focus. CustomEvent<any>

Methods #

setFocus() => Promise<void> #

Sets focus on the specified duet-select. Use this method instead of the global
select.focus().

Returns #

Type: Promise<void>

Dependencies #

Used by #

Depends on #

Graph #

graph TD;
duet-select --> duet-label
duet-select --> duet-tooltip
duet-tooltip --> duet-visually-hidden
duet-tab-group --> duet-select
style duet-select fill:#f9f,stroke:#333,stroke-width:4px

Integration

For integration, event and theming guidelines, please see Using Components. This documentation explains how to implement and use Duet’s components across different technologies like Angular, React or Vanilla JavaScript.



Tutorials

Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:

Tutorials

Building Layouts

Tutorials

Server Side Rendering


Troubleshooting

If you experience any issues while using a component, please head over to the Support page for more guidelines and help.