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

@leafygreen-ui/select

Package Overview
Dependencies
Maintainers
2
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@leafygreen-ui/select

leafyGreen UI Kit Select

  • 2.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
89K
increased by81.47%
Maintainers
2
Weekly downloads
 
Created
Source

Select

npm (scoped)

View on MongoDB.design

Installation

Yarn

yarn add @leafygreen-ui/select

NPM

npm install @leafygreen-ui/select

Example

import { Option, OptionGroup, Select, Size } from '@leafygreen-ui/select';

<Select
  label="Label"
  description="Description"
  placeholder="Placeholder"
  name="Name"
  size={Size.Default}
  defaultValue="cat"
>
  <Option value="dog">Dog</Option>
  <Option value="cat">Cat</Option>
  <OptionGroup label="Less common">
    <Option value="hamster">Hamster</Option>
    <Option value="parrot">Parrot</Option>
  </OptionGroup>
</Select>;

Output HTML

<div class="">
  <label id="select-7-label" class="leafygreen-ui-xzhurf">Label</label>
  <div id="select-7-description" class="leafygreen-ui-3gds6m">Description</div>
  <button
    type="button"
    class="leafygreen-ui-1fdrra0"
    aria-disabled="false"
    aria-labelledby="select-7-label"
    aria-controls="select-7-menu"
    aria-expanded="false"
    aria-describedby="select-7-description"
    name="Name"
    value="cat"
  >
    <span class="leafygreen-ui-tdo6z2"
      ><div class="leafygreen-ui-ogsjyj">
        <span class="leafygreen-ui-1ks3bq2">Cat</span
        ><svg
          class="leafygreen-ui-1jr2j1f"
          height="16"
          width="16"
          role="presentation"
          aria-hidden="true"
          alt=""
          viewBox="0 0 16 16"
        >
          <g
            id="CaretDown-Copy"
            stroke="none"
            stroke-width="1"
            fill="none"
            fill-rule="evenodd"
          >
            <path
              d="M4.67285687,6 L11.3271431,6 C11.9254697,6 12.224633,6.775217 11.8024493,7.22717749 L8.47530616,10.7889853 C8.21248981,11.0703382 7.78751019,11.0703382 7.52748976,10.7889853 L4.19755071,7.22717749 C3.77536701,6.775217 4.07453029,6 4.67285687,6 Z"
              id="Path"
              fill="currentColor"
            ></path>
          </g>
        </svg>
      </div>
      <div></div
    ></span>
  </button>
</div>

Select Properties

PropTypeDescriptionDefault
childrennode<Option /> and <OptionGroup /> elements.
classNamestringAdds a className to the outermost element.
darkModebooleanDetermines whether or not the component will appear in dark mode.false
size'xsmall', 'small', 'default', 'large'Sets the size of the component's elements.'default'
idstringid associated with the Select component.
namestringThe name that will be used when submitted as part of a form.
labelstringText shown in bold above the input element.
aria-labelledbystringMust be provided if and only if label is not provided.
descriptionstringText that gives more detail about the requirements for the input.
placeholderstringThe placeholder text shown in the input element when an option is not selected.'Select'
disabledbooleanDisables the component from being edited.false
valuestringSets the <Option /> that will appear selected and makes the component a controlled component.''
defaultValuestringSets the <Option /> that will appear selected on page load when the component is uncontrolled.''
onChangefunctionA function that gets called when the selected value changes. Receives the value string as the first argument.() => {}
readOnlybooleanDisables the console warning when the component is controlled and no onChange prop is provided.false
usePortalbooleanDetermines if Select dropdown will be portaled to the end of the DOMtrue

Option

PropTypeDescriptionDefault
childrennodeContent to appear inside of the component.
classNamestringAdds a className to the outermost element.
glyphReact.ReactElementIcon to display next to the option text.
valuestringCorresponds to the value passed into the onChange prop of <Select /> when the option is selected.text contents of children
disabledbooleanPrevents the option from being selectable.false

OptionGroup

PropTypeDescriptionDefault
childrennode<Option /> elements
classNamestringAdds a className to the outermost element.
labelstringText shown above the group's options.
disabledbooleanPrevents all the contained options from being selectable.false

FAQs

Package last updated on 22 Apr 2021

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