Socket
Socket
Sign inDemoInstall

@leafygreen-ui/search-input

Package Overview
Dependencies
14
Maintainers
6
Versions
43
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @leafygreen-ui/search-input

leafyGreen UI Kit Search Input


Version published
Weekly downloads
12K
decreased by-7.91%
Maintainers
6
Created
Weekly downloads
 

Readme

Source

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.

FAQs

Last updated on 30 Aug 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc