Select
Inmatningsfält som används för att välja exakt ett alternativ.
Installation
- npm
- Yarn
- pnpm
npm install @midas-ds/components
yarn add @midas-ds/components
pnpm add @midas-ds/components
import { Item, Select } from '@midas-ds/components'
Riktlinjer
Om det är färre alternativ än fem bör Radio användas istället.
API
Select
Namn | Typ | Standard | Beskrivning |
---|---|---|---|
label | string | - | |
description | string | - | |
errorMessage | string | ((validation: ValidationResult) => string) | - | |
items | Iterable<T> | - | |
isDisabled | boolean | - | Whether the input is disabled. |
className | string | ((values: SelectRenderProps & { defaultClassName: string; }) => string) | - | The CSS [className](https://developer.mozilla.org/en-US/docs/Web/API/Element/className) for the element. A function may be provided to compute the class based on component state. |
style | CSSProperties | ((values: SelectRenderProps & { defaultStyle: CSSProperties; }) => CSSProperties) | - | The inline [style](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style) for the element. A function may be provided to compute the style based on component state. |
id | string | - | The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). |
slot | string | - | A slot name for the component. Slots allow the component to receive props from a parent component. An explicit `null` value indicates that the local props completely override all props received from a parent. |
autoFocus | boolean | - | Whether the element should receive focus on render. |
excludeFromTabOrder | boolean | - | Whether to exclude the element from the sequential tab order. If true, the element will not be focusable via the keyboard by tabbing. This should be avoided except in rare scenarios where an alternative means of accessing the element or its functionality via the keyboard is available. |
name | string | - | The name of the input, used when submitting an HTML form. |
validationBehavior | "native" | "aria" | 'native' | Whether to use native HTML form validation to prevent form submission when the value is missing or invalid, or mark the field as required or invalid via ARIA. |
isRequired | boolean | - | Whether user input is required on the input before form submission. |
isInvalid | boolean | - | Whether the input value is invalid. |
validate | (value: Key) => true | ValidationError | - | A function that returns an error message if a given value is invalid. Validation errors are displayed to the user when the form is submitted if `validationBehavior="native"`. For realtime validation, use the `isInvalid` prop instead. |
placeholder | string | - | Temporary text that occupies the text input when it is empty. |
selectedKey | Key | - | The currently selected key in the collection (controlled). |
defaultSelectedKey | Key | - | The initial selected key in the collection (uncontrolled). |
disabledKeys | Iterable<Key> | - | The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with. |
isOpen | boolean | - | Sets the open state of the menu. |
defaultOpen | boolean | - | Sets the default open state of the menu. |
autoComplete | string | - | Describes the type of autocomplete functionality the input should provide if any. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefautocomplete). |