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

@leafygreen-ui/select

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

  • 11.1.3-popover.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
89K
increased by81.47%
Maintainers
6
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" description="Bark">
    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 neither label nor aria-label is not provided.
aria-labelstringMust be provided if and only if neither label nor aria-labelledby 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
allowDeselectbooleanEnables or disables the option for a user to select a null default value.true
usePortalbooleanDetermines if Select dropdown will be rendered inside a portal.true
portalContainerHTMLElement | nullSets the container used for the popover's portal. NOTE: If using a scrollContainer make sure that the portalContainer is contained within the scrollContainer. E.g, passing the same refrence to scrollContainer and portalContainer.
scrollContainerHTMLElement | nullIf the popover portal has a scrollable ancestor other than the window, this prop allows passing a reference to that lement to allow the portal to position properly.
portalClassNamestringPasses the given className to the popover's portal container if the default portal container is being used.
popoverZIndexnumberSets the z-index CSS property for the popover.
state'none', 'error'Determines the state of the <select>'none'
errorMessagestringText that shows when the state is set to error.
baseFontSize'13', '16'Determines the base font size if sizeVariant is set to default'13'
dropdownWidthBasis'option' | 'trigger'Determines the width of the dropdown. trigger will make the dropdown width the width of the menu trigger. option will make the dropdown width as wide as the widest option.trigger

Option

PropTypeDescriptionDefault
childrenstring, numberContent 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
descriptionstringOptional descriptive text under the value
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 16 Jan 2024

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