3.0.1 • Published 24 days ago

@leafygreen-ui/search-input v3.0.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
24 days ago

Search Input

npm (scoped)

View on MongoDB.design

Installation

Yarn

yarn add @leafygreen-ui/search-input

NPM

npm install @leafygreen-ui/search-input

Example

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

PropTypeDescriptionDefault
darkModebooleanDetermines 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
disabledbooleanDetermines whether the field is currently disabled.false
valuestringThe current value of the text box.''
placeholderstringThe placeholder text shown in the input field before the user begins typing.Search
aria-labelledbystringA value for aria-labelledby. Allows use of the component with an external <label> element.
aria-labelstringA value for aria-label. Allows use of the component without a label.
onChangeChangeEventHandler<HTMLInputElement>Callback fired when the input value changes. Use this callback to filter the SearchResult options.
onSubmitFormEventHandler<HTMLFormElement>Callback fired when a search result is clicked, or the enter key is pressed.''
...native form attributesAny other properties will be spread on the root form element.

SearchResult

Props

PropTypeDescriptionDefault
childrenReact.ReactNodeThe value of the result.
descriptionReact.ReactNodeOptional description text.
onClickReact.MouseEventHandlerCallback fired when the option is clicked.
asReact.ElementTypeThe component or element to render as.li
disabledbooleanPrevents the option from being selectable.false
highlightedbooleanDefines the currently highlighted option element for keyboard navigation. Not to be confused with selected, which identifies the currently selected optionfalse
selectedbooleanWhether the component is selected, regardless of keyboard navigationfalse
hrefstringhref is required for Anchor tags
...native as attributesAny other properties will be spread on the root as element.

SearchResultGroup

Props

PropTypeDescriptionDefault
childrenReact.ReactNodeMust be <SearchResult/> or <SearchResultGroup/>.
labelstringTitle for the group of options.
...native div attributesAny other properties will be spread on the root div element.
3.0.1

24 days ago

3.0.0

1 month ago

2.1.6

1 month ago

2.1.5

2 months ago

2.1.4

2 months ago

2.1.3

3 months ago

2.1.3-popover.0

4 months ago

2.1.2

7 months ago

2.0.15

8 months ago

2.1.1

8 months ago

2.0.16

8 months ago

2.0.13

9 months ago

3.0.0-alpha.1

10 months ago

2.0.14

9 months ago

3.0.0-alpha.0

10 months ago

2.0.11

9 months ago

2.0.12

9 months ago

2.0.9

10 months ago

2.0.10

9 months ago

2.1.0

8 months ago

2.0.17

8 months ago

2.0.6-next.7

12 months ago

2.0.6-next.6

12 months ago

2.0.6-next.5

12 months ago

2.0.6-next.4

12 months ago

2.0.6-next.3

12 months ago

2.0.6-next.2

12 months ago

2.0.6-next.1

12 months ago

2.0.6-next.0

12 months ago

2.0.5

12 months ago

2.0.4

12 months ago

2.0.7

11 months ago

2.0.6

12 months ago

2.0.8

11 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

1.0.4

1 year ago

2.0.0

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago