You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@s-ui/react-molecule-select-field

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@s-ui/react-molecule-select-field

`MoleculeSelectField` is a component that wraps a composition of Label + some input (input, textarea, ...) + Validation Messages for a [`MoleculeSelect`](https://sui-components.now.sh/workbench/molecule/select/demo) component

2.1.0
latest
Source
npmnpm
Version published
Weekly downloads
4.8K
-3.57%
Maintainers
0
Weekly downloads
 
Created
Source

MoleculeSelectField

MoleculeSelectField is a component that wraps a composition of Label + some input (input, textarea, ...) + Validation Messages for a MoleculeSelect component

documentation issue npm

Issues open NPM

Installation

$ npm install @s-ui/react-molecule-select-field --save

Usage

After importing the component MoleculeSelectField like this

import MoleculeSelectField from '@s-ui/react-molecule-select-field'
import MoleculeSelectOption from '@s-ui/react-molecule-dropdown-option'

const IconCloseTag = () => <span>x</span>  
const IconArrowDown = () => <span></span>  

const options = ['John','Paul','George','Ringo']

Basic usage

<MoleculeSelectField
  label="Country"
  placeholder="Select a Country..."
  onChange={(_, {value}) => console.log(value)}
  iconArrowDown={<IconArrowDown />}
>
  {options.map((option, i) => (
    <MoleculeSelectOption key={i} value={option}>
      {option}
    </MoleculeSelectOption>
  ))}
</MoleculeSelectField>

Basic usage with multiselection

<MoleculeSelectField
  label="Country"
  placeholder="Select a Country..."
  onChange={(_, {value}) => console.log(value)}
  iconArrowDown={<IconArrowDown />}
  iconCloseTag={<IconCloseTag />}
  multiselection
>
  {options.map((option, i) => (
    <MoleculeSelectOption key={i} value={option}>
      {option}
    </MoleculeSelectOption>
  ))}
</MoleculeSelectField>

With Error Message

<MoleculeSelectField
    label="Country"
    placeholder="Select a Country..."
    onChange={(_, {value}) => console.log(value)}
    iconArrowDown={<IconArrowDown />}
    errorText="Error!"
  >
    {options.map((option, i) => (
      <MoleculeSelectOption key={i} value={option}>
        {option}
      </MoleculeSelectOption>
    ))}
</MoleculeSelectField>

With Alert Message

<MoleculeSelectField
    label="Country"
    placeholder="Select a Country..."
    onChange={(_, {value}) => console.log(value)}
    iconArrowDown={<IconArrowDown />}
    alertText="Error!"
  >
    {options.map((option, i) => (
      <MoleculeSelectOption key={i} value={option}>
        {option}
      </MoleculeSelectOption>
    ))}
</MoleculeSelectField>

With Success Message

<MoleculeSelectField
    label="Country"
    placeholder="Select a Country..."
    onChange={(_, {value}) => console.log(value)}
    iconArrowDown={<IconArrowDown />}
    successText="Success!"
  >
    {options.map((option, i) => (
      <MoleculeSelectOption key={i} value={option}>
        {option}
      </MoleculeSelectOption>
    ))}
</MoleculeSelectField>

With Help Text

<MoleculeSelectField
    label="Country"
    placeholder="Select a Country..."
    onChange={(_, {value}) => console.log(value)}
    iconArrowDown={<IconArrowDown />}
    helpText="Read the instructions to write proper format"
  >
    {options.map((option, i) => (
      <MoleculeSelectOption key={i} value={option}>
        {option}
      </MoleculeSelectOption>
    ))}
</MoleculeSelectField>

State Management for this componente

Like MoleculeSelect, MoleculeSelectField can also use the withStateValue hoc to create a stateful version of this component

import {withStateValue} from '@s-ui/hoc'
import MoleculeSelectField from '@s-ui/react-molecule-select-field'

...

const MoleculeSelectFieldWithState = withStateValue(MoleculeSelectField)

Find full description and more examples in the demo page.

Keywords

@s-ui

FAQs

Package last updated on 24 Feb 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.