A common form component for choosing a predefined value in a dropdown menu.
import { Select } from '@backstage/ui';
<Select
name="font"
options={[
{ value: 'sans', label: 'Sans-serif' },
{ value: 'serif', label: 'Serif' },
{ value: 'mono', label: 'Monospace' },
{ value: 'cursive', label: 'Cursive' },
]}
/>| Prop | Type | Default | Responsive |
|---|---|---|---|
| label | string | - | No |
| description | string | - | No |
| name | string | - | No |
| options | Array<{ value: string, label: string }> | - | No |
| placeholder | string | Select an item | No |
| icon | ReactNode | - | No |
| value | string | - | No |
| defaultValue | string | - | No |
| size | smallmedium | medium | Yes |
| isOpen | boolean | - | No |
| defaultOpen | boolean | - | No |
| disabledKeys | string[] | - | No |
| isDisabled | boolean | - | No |
| isRequired | boolean | - | No |
| isInvalid | boolean | - | No |
| selectedKey | string | - | No |
| defaultSelectedKey | string | - | No |
| onOpenChange | (isOpen: boolean) => void | - | No |
| onSelectionChange | (key: Key | null) => void | - | No |
| className | string | - | No |
| style | CSSProperties | - | No |
Select component with label and description.
<Select
name="font"
label="Font Family"
description="Choose a font family for your document"
options={[ ... ]}
/>Here's a view when the selects have different sizes.
<Flex>
<Select
size="small"
label="Font family"
options={[ ... ]}
/>
<Select
size="medium"
label="Font family"
options={[ ... ]}
/>
</Flex>Here's a view when the select has an icon.
<Select
name="font"
label="Font Family"
icon={<RiCloudLine />}
options={[ ... ]}
/>Here's a view when the select is disabled.
<Select
disabled
label="Font family"
options={[ ... ]}
/>Here's a view when the select is responsive.
<Select
size={{ initial: 'small', lg: 'medium' }}
label="Font family"
options={[ ... ]}
/>Our theming system is based on a mix between CSS classes, CSS variables and data attributes. If you want to customise this component, you can use one of these class names below.
bui-Selectbui-Select[data-size="small"]bui-Select[data-size="medium"]bui-SelectTriggerbui-SelectValuebui-SelectIconbui-SelectListbui-SelectItembui-SelectItemIndicatorbui-SelectItemLabel