Select Field
Select Field wraps a Select input and its corresponding Label. It allows users to select one option from a set.
Overview
Import
Import the component from @faststore/ui
import { SelectField } from '@faststore/ui'
Import Styles
import '@faststore/ui/src/components/molecules/SelectField/styles.scss'
Usage
<SelectField
id="select-order-by"
label="Order by:"
options={{
name_asc: 'Name, A-Z',
name_desc: 'Name, Z-A',
top_sales: 'Top Sales',
}}
/>
Props
Name | Type | Description | Default |
---|---|---|---|
label* | string | Defines the text displayed in the label right next to the Select. | |
testId | string | ID to find this component in testing tools (e.g.: cypress, testing library, and jest). | fs-select-field |
id* | string | Assigns an identifier to link the UISelect component and its label. | |
options* | Record<string, string> | Defines the options available in the select. The SelectOptions object keys are the property names, while the values correspond to the text that will be displayed in the UI. |
Design Tokens
Local token | Default value/Global token linked |
---|---|
--fs-select-label-color | var(--fs-color-text-light) |
--fs-select-label-margin-right | var(--fs-spacing-1) |
Customization
For further customization, you can use the following data attributes:
data-fs-select-field
data-fs-select-field-label