Components
Examples
A basic search input
<SearchInput label="Search" />
A controlled search input
() => { const [query, setQuery] = React.useState(""); return ( <SearchInput label="Search" value={query} onChange={e => setQuery(e.target.value)} /> ); }
A search input with a reset button
() => { const [query, setQuery] = React.useState(""); return ( <SearchInput label="Search" value={query} onChange={e => setQuery(e.target.value)} onReset={() => setQuery("")} /> ); }
Different variants
<Stack gap={3}> <SearchInput label="Base" /> <SearchInput label="Floating" variant="floating" /> </Stack>
Guidelines
A SearchInput is used for searching for content.
You may use functions like "reset" and others.
Code
<SearchInput />
import { SearchInput } from "@vygruppen/spor-react";
Input for searching or filtering content
Props
Name | Type | Required? | Description |
|---|---|---|---|
value | string | The value, if controlled | |
onChange | function | Callback for when the value changes | |
onReset | function | Callback for when the input is reset. When this is specified, a reset button appears to the right of the input field | |
label | string | The label of the input field. Default "Search" (localized) | |
variant | "core" | "floating" | Defaults to core. |