2.1.6 • Published 2 years ago
@leafygreen-ui/search-input v2.1.6
Search Input
View on MongoDB.design
Installation
Yarn
yarn add @leafygreen-ui/search-inputNPM
npm install @leafygreen-ui/search-inputExample
import {
SearchInput,
SearchResult,
SearchResultGroup,
} from '@leafygreen-ui/search-input';
<SearchInput
className={css`
width: 200px;
`}
onChange={() => {
console.log('SB: Change');
}}
aria-label="some label"
>
<SearchResult
onClick={() => {
console.log('SB: Click Apple');
}}
description="This is a description"
>
Apple
</SearchResult>
<SearchResult>Banana</SearchResult>
<SearchResult as="a" href="#" description="This is a link">
Carrot
</SearchResult>
<SearchResult description="This is a very very long description. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.">
Dragonfruit
</SearchResult>
<SearchResultGroup label="Peppers">
<SearchResult description="A moderately hot chili pepper used to flavor dishes">
Cayenne
</SearchResult>
<SearchResult>Ghost pepper</SearchResult>
<SearchResult>Habanero</SearchResult>
<SearchResult>Jalapeño</SearchResult>
<SearchResult>Red pepper</SearchResult>
<SearchResult>Scotch bonnet</SearchResult>
</SearchResultGroup>
</SearchInput>;Properties
| Prop | Type | Description | Default |
|---|---|---|---|
darkMode | boolean | Determines whether or not the component appears in dark theme. | false |
state | 'none', 'loading', | The current state of the SearchInput. | none |
size | 'small', 'default', 'large' | Determines the font size, padding and spacing. | default |
disabled | boolean | Determines whether the field is currently disabled. | false |
value | string | The current value of the text box. | '' |
placeholder | string | The placeholder text shown in the input field before the user begins typing. | Search |
aria-labelledby | string | A value for aria-labelledby. Allows use of the component with an external <label> element. | |
aria-label | string | A value for aria-label. Allows use of the component without a label. | |
onChange | ChangeEventHandler<HTMLInputElement> | Callback fired when the input value changes. Use this callback to filter the SearchResult options. | |
onSubmit | FormEventHandler<HTMLFormElement> | Callback fired when a search result is clicked, or the enter key is pressed. | '' |
... | native form attributes | Any other properties will be spread on the root form element. |
SearchResult
Props
| Prop | Type | Description | Default |
|---|---|---|---|
children | React.ReactNode | The value of the result. | |
description | React.ReactNode | Optional description text. | |
onClick | React.MouseEventHandler | Callback fired when the option is clicked. | |
as | React.ElementType | The component or element to render as. | li |
disabled | boolean | Prevents the option from being selectable. | false |
highlighted | boolean | Defines the currently highlighted option element for keyboard navigation. Not to be confused with selected, which identifies the currently selected option | false |
selected | boolean | Whether the component is selected, regardless of keyboard navigation | false |
href | string | href is required for Anchor tags | |
... | native as attributes | Any other properties will be spread on the root as element. |
SearchResultGroup
Props
| Prop | Type | Description | Default |
|---|---|---|---|
children | React.ReactNode | Must be <SearchResult/> or <SearchResultGroup/>. | |
label | string | Title for the group of options. | |
... | native div attributes | Any other properties will be spread on the root div element. |
4.0.0
1 year ago
5.0.9
9 months ago
5.0.8
10 months ago
5.0.7
10 months ago
5.0.6
10 months ago
5.0.5
10 months ago
5.0.4
11 months ago
5.0.3
11 months ago
5.0.2
12 months ago
5.0.1
12 months ago
5.0.10
9 months ago
5.0.0
1 year ago
5.0.11
9 months ago
5.0.12
9 months ago
5.0.13
9 months ago
5.0.14
8 months ago
6.0.0
8 months ago
3.1.4
1 year ago
3.1.3
1 year ago
3.1.2
2 years ago
3.1.1
2 years ago
3.1.0
2 years ago
3.0.1
2 years ago
3.0.0
2 years ago
2.1.6
2 years ago
2.1.5
2 years ago
2.1.4
2 years ago
2.1.3
2 years ago
2.1.3-popover.0
2 years ago
2.1.2
2 years ago
2.0.15
2 years ago
2.1.1
2 years ago
2.0.16
2 years ago
2.0.13
2 years ago
3.0.0-alpha.1
2 years ago
2.0.14
2 years ago
3.0.0-alpha.0
2 years ago
2.0.11
2 years ago
2.0.12
2 years ago
2.0.9
2 years ago
2.0.10
2 years ago
2.1.0
2 years ago
2.0.17
2 years ago
2.0.6-next.7
3 years ago
2.0.6-next.6
3 years ago
2.0.6-next.5
3 years ago
2.0.6-next.4
3 years ago
2.0.6-next.3
3 years ago
2.0.6-next.2
3 years ago
2.0.6-next.1
3 years ago
2.0.6-next.0
3 years ago
2.0.5
3 years ago
2.0.4
3 years ago
2.0.7
3 years ago
2.0.6
3 years ago
2.0.8
3 years ago
2.0.3
3 years ago
2.0.2
3 years ago
2.0.1
3 years ago
1.0.4
3 years ago
2.0.0
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago