Select
Use Select to pick from a set of options in a dropdown.
To add the Select
component to your app:
import {Select} from '@stripe/ui-extension-sdk/ui';
<Select name="demo-001" label="Choose a pet" onChange={(e) => { console.log(e); }} > <option value="">Choose an option</option> <option value="dogs">Dogs</option> <option value="cats">Cats</option> </Select>
Select props
Property | Type |
---|---|
| Required
The contents of the component. |
| Optional
Specifies one of the possible autocomplete behaviors. |
| Optional
If |
| Optional
Related types: CSS. |
| Optional
A string (or an array of strings for |
| Optional
Descriptive text that will be rendered adjacent to the control’s label. |
| Optional
Sets whether or not the element should be disabled. Prevents selection. |
| Optional
Error text that will be rendered below the control. |
| Optional
Specifies the |
| Optional
Visually hides the specified elements. The hidden elements will still be present and visible to screen readers. |
| Optional
Sets whether or not the element is in an invalid state. This is a display-only prop, and will not prevent form submission. |
| Optional
Text that describes the control. Will be both visible and clickable. |
| Optional
If |
| Optional
Specifies the name for this input that’s submitted with the form. |
| Optional
Required for controlled inputs. Fires immediately when the input’s value is changed by the user (for example, it fires on every keystroke). Behaves like the browser input event. |
| Optional
If |
| Optional
The size of the component. |
| Optional
A string (or an array of strings for |
CSS
Property | Type |
---|---|
| Optional
The width of the component. See Sizing for details. |
State management
Use the Select
component as an uncontrolled input:
<Select name="demo-001" label="Choose a pet" onChange={(e) => { console.log(e); }} > <option value="">Choose an option</option> <option value="dogs">Dogs</option> <option value="cats">Cats</option> </Select>
Disabled
You can disable a Select
component, which prevents changes.
<Select name="demo-001" disabled label="Choose a pet"> <option value="">Choose an option</option> <option value="dogs">Dogs</option> <option value="cats">Cats</option> </Select>
Width
Set the width of a Select
component using the available values with the css
prop:
<Select css={{ width: 'fill', }} name="demo-001" label="Choose a pet" onChange={(e) => { console.log(e); }} > <option value="">Choose an option</option> <option value="dogs">Dogs</option> <option value="cats">Cats</option> </Select>