Hoppa till huvudinnehåll

Select

Flerval, väljare, dropdown

Select är en typ av inmatningsfält som används för att välja ett alternativ från en uppsättning av flera alternativ. Om det är färre alternativ än fem bör Radio användas istället.

Installation och användning

npm install @midas-ds/select
import { Item, Select } from '@midas-ds/select'

Beroenden

  • @midas-ds/theme@^0.5.23
  • react-aria-components@^1.1.0
  • react@^18.2.0

Riktlinjer

Val av komponent

API

Select

NamnTypStandardBeskrivning
label string-
description string-
errorMessage string | ((validation: ValidationResult) => string)-
items Iterable<T>-
defaultOpen boolean-Sets the default open state of the menu.
isDisabled boolean-Whether the input is disabled.
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.
id string-The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
name string-The name of the input, used when submitting an HTML form.
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.
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.
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.
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).

Item

Beroenden

  • @midas-ds/theme@^0.5.23
  • react-aria-components@^1.1.0
  • react@^18.2.0