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

@leafygreen-ui/select

Package Overview
Dependencies
Maintainers
3
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

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
140K
increased by72.15%
Maintainers
3
Weekly downloads
 
Created
Source

Select

npm (scoped)

View on Storybook

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"
    role="combobox"
    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-msi0rg"
          height="16"
          width="16"
          viewBox="0 0 16 16"
          role="img"
          aria-labelledby="CaretDown-7"
        >
          <title id="CaretDown-7">Caret Down Icon</title>
          <desc>Created with Sketch.</desc>
          <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.

| label | string | Text shown in bold above the input element. | | | aria-labelledby | string | Must be provided if and only if label is not provided. | | | description | string | Text that gives more detail about the requirements for the input. | | | placeholder | string | The placeholder text shown in the input element when an option is not selected. | 'Select' | | disabled | boolean | Disables the component from being edited. | false | | value | string | Sets the <Option /> that will appear selected and makes the component a controlled component. | '' | | defaultValue | string | Sets the <Option /> that will appear selected on page load when the component is uncontrolled. | '' | | onChange | function | A function that gets called when the selected value changes. Receives the value string as the first argument. | () => {} | | readOnly | boolean | Disables the console warning when the component is controlled and no onChange prop is provided. | false |

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 17 Dec 2020

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