Hoppa till huvudinnehåll

SearchField

Inmatningsfält anpassat för sökning.

<SearchField placeholder='Sök efter frukter' />

Installation

npm install @midas-ds/components
import { SearchField } from '@midas-ds/components'

API

NameTypeDefaultDescription
placeholder *string-

Placeholder text

buttonTextstring'Sök'

Text displayed on the 'search' button

errorMessagestring-

A custom error message if using the isInvalid prop.

errorPositiontop
sizelarge

Component size (large: height 48px, medium: height 40px)

isDisabled-

Whether the input is disabled.

children-

The children of the component. A function may be provided to alter the children based on component state.

className-

The CSS className for the element. A function may be provided to compute the class based on component state.

style-

The inline style for the element. A function may be provided to compute the style based on component state.

idstring-

The element's unique identifier. See MDN.

slotstring-

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.

type-

The type of input to render. See MDN.

defaultValuestring-

The default value (uncontrolled).

autoFocus-

Whether the element should receive focus on render.

spellCheckstring-

An enumerated attribute that defines whether the element may be checked for spelling errors. See MDN.

autoCorrectstring-

An attribute that takes as its value a space-separated string that describes what, if any, type of autocomplete functionality the input should provide. See MDN.

inputMode-

Hints at the type of data that might be entered by the user while editing the element or its contents. See MDN.

excludeFromTabOrder-

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.

namestring-

The name of the input element, used when submitting an HTML form. See MDN.

valuestring-

The current value (controlled).

isReadOnly-

Whether the input can be selected but not changed by the user.

isInvalid-

Whether the input value is invalid.

patternstring-

Regex pattern that the value of the input must match to be valid. See MDN.

autoCompletestring-

Describes the type of autocomplete functionality the input should provide if any. See MDN.

enterKeyHint-

An enumerated attribute that defines what action label or icon to preset for the enter key on virtual keyboards. See MDN.

maxLengthnumber-

The maximum number of characters supported by the input. See MDN.

minLengthnumber-

The minimum number of characters required by the input. See MDN.

validationBehavior'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.

validate(value: string) => 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.