Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@leafygreen-ui/search-input

Package Overview
Dependencies
Maintainers
6
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafygreen-ui/search-input

leafyGreen UI Kit Search Input

  • 2.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-29.75%
Maintainers
6
Weekly downloads
 
Created
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

Package last updated on 19 Sep 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc