Back to Tuist

Select

noora/docs/components/select.md

4.204.03.5 KB
Original Source
<!-- Generated by scripts/generate-web-components.js. Do not edit directly. -->

Select

Selects one value from a list of options.

html
<noora-select label="Country" name="country">
  <option value="es">Spain</option>
</noora-select>

Attributes

AttributeType or allowed valuesDefaultDescription
labelstring""Sets the placeholder label.
namestring""Sets the submitted field name.
valuestring""Gets or sets the selected value.
hintstringNoneAdds supporting text.
disabledbooleanfalseDisables the select.
requiredbooleanfalseMarks the field as required.
openbooleanfalseControls whether the options menu is open.

Properties

PropertyType or allowed valuesDefaultDescription
optionsArray<Record<string, unknown>>[]Defines options programmatically when declarative option children are not used. Each option can include label, value, icon, and disabled fields.

Read-only properties

PropertyTypeDescription
controlHTMLSelectElement | nullThe native select control.
formHTMLFormElement | nullThe associated form.

Events

EventTypeDescription
inputInputEventEmitted while the selected value changes.
changeEventEmitted after the selected value changes.
noora-open-changeCustomEvent<{ open: boolean }>Emitted when the options menu opens or closes.
noora-selectCustomEvent<{ item: Record<string, unknown>; value: string }>Emitted with the selected option and value.

Slots

SlotDescription
defaultDeclarative native option children.

Styling parts

PartDescription
selectThe visible select trigger.
contentThe options menu.
itemsThe options list.
hintThe supporting text.

The component emits standard input and change events.

Use data-icon on a declarative option to show an icon in the menu and selected trigger.

Default

Select a country from structured options.

html
<noora-select label="Country" name="country">
  <option value="es">Spain</option>
  <option value="de">Germany</option>
  <option value="fr">France</option>
</noora-select>

Selected value

Show the current value in the trigger.

html
<noora-select label="Country" name="country" value="de">
  <option value="es">Spain</option>
  <option value="de">Germany</option>
  <option value="fr">France</option>
</noora-select>

Option icons

Add visual context to options and the selected trigger.

html
<noora-select label="Workspace" name="workspace" value="application">
  <option value="application" data-icon="category">Application</option>
  <option value="framework" data-icon="category">Framework</option>
  <option value="package" data-icon="category">Package</option>
</noora-select>

Hint

Explain how the selected value will be used.

html
<noora-select label="Country" name="country" hint="Used for regional settings.">
  <option value="es">Spain</option>
  <option value="de">Germany</option>
  <option value="fr">France</option>
</noora-select>

Disabled

Disable selection when the field is unavailable.

html
<noora-select label="Country" name="country" value="de" disabled>
  <option value="es">Spain</option>
  <option value="de">Germany</option>
  <option value="fr">France</option>
</noora-select>