Skip to main content
Version: 1.x

fast-select

An implementation of an HTML select element as a form-connected web-component.

Setup

Basic Setup

import {
provideFASTDesignSystem,
fastSelect,
fastOption,
} from "@microsoft/fast-components";

provideFASTDesignSystem().register(fastSelect(), fastOption());

Customizing the Indicator

import {
provideFASTDesignSystem,
fastSelect,
fastOption,
} from "@microsoft/fast-components";

provideFASTDesignSystem().register(
fastSelect({
indicator: `...your indicator...`,
}),
fastOption()
);

Usage

Live Editor
<fast-select id="shirt-size">
    <fast-option value="s">Small</fast-option>
    <fast-option value="m">Medium</fast-option>
    <fast-option value="l">Large</fast-option>
    <fast-option value="xl">Extra Large</fast-option>
</fast-select>
Result
Loading...

Create your own design

Select

import {
Select,
SelectOptions,
selectTemplate as template,
} from "@microsoft/fast-foundation";
import { selectStyles as styles } from "./my-select.styles";

export const mySelect = Select.compose<SelectOptions>({
baseName: "select",
template,
styles,
indicator: `...default indicator...`,
});

Option

See listbox-option for more information.

API

Variables

NameDescriptionType
SelectPositionPositioning directions for the listbox when a select is open.{ above: "above", below: "below", }

class: Select

Superclass

NameModulePackage
FormAssociatedSelect/src/select/select.form-associated.js

Static Fields

NamePrivacyTypeDefaultDescriptionInherited From
slottedOptionFilterpublicA static filter to include only selectable options.Listbox

Fields

NamePrivacyTypeDefaultDescriptionInherited From
openpublicbooleanfalseThe open attribute.
valuepublicThe value property.
positionAttributepublicSelectPosition or undefinedReflects the placement for the listbox when the select is open.
positionpublicSelectPosition or undefinedHolds the current state for the calculated position of the listbox.
displayValuepublicstringThe value displayed on the button.
proxyFormAssociatedSelect
multiplepublicbooleanIndicates if the listbox is in multi-selection mode.ListboxElement
sizepublicnumberThe maximum number of options to display.ListboxElement
lengthpublicnumberThe number of options.Listbox
optionspublicListboxOption[]The list of options.Listbox
typeAheadExpiredprotectedListbox
disabledpublicbooleanThe disabled state of the listbox.Listbox
selectedIndexpublicnumber-1The index of the selected option.Listbox
selectedOptionspublicListboxOption[][]A collection of the selected options.Listbox
$presentationpublicComponentPresentation or nullA property which resolves the ComponentPresentation instance for the current component.FoundationElement
templatepublicElementViewTemplate or void or nullSets the template of the element instance. When undefined, the element will attempt to resolve the template from the associated presentation or custom element definition.FoundationElement
stylespublicElementStyles or void or nullSets the default styles for the element instance. When undefined, the element will attempt to resolve default styles from the associated presentation or custom element definition.FoundationElement

Methods

NamePrivacyDescriptionParametersReturnInherited From
positionChangedprotectedprev: SelectPosition or undefined, next: SelectPosition or undefinedvoid
setPositioningpublicCalculate and apply listbox positioning based on available viewport space.void
multipleChangedpublicSets the multiple property on the proxy element.prev: boolean or undefined, next: boolean
setSelectedOptionspublicSets an option as selected and gives it focus.Listbox
selectFirstOptionpublicMoves focus to the first selectable option.voidListbox
templateChangedprotectedvoidFoundationElement
stylesChangedprotectedvoidFoundationElement

Events

NameTypeDescriptionInherited From
inputFires a custom 'input' event when the value updates
changeFires a custom 'change' event when the value updates

Attributes

NameFieldInherited From
openopen
positionpositionAttribute
multipleListbox

CSS Parts

NameDescription
controlThe element representing the select invoking element
selected-valueThe element wrapping the selected value
indicatorThe element wrapping the visual indicator
listboxThe listbox element

Slots

NameDescription
startContent which can be provided before the button content
endContent which can be provided after the button content
button-containerThe element representing the select button
selected-valueThe selected value
indicatorThe visual indicator for the expand/collapse state of the button
The default slot for slotted options

class: DelegatesARIASelect

Fields

NamePrivacyTypeDefaultDescriptionInherited From
ariaControlspublicstring or nullSee https://www.w3.org/TR/wai-aria-1.2/#combobox for more information

Additional resources