🎨
Valence
🎨
Valence
  • Overview
    • 👋Welcome to Valence
    • 🏄‍♂️Getting started
  • Core Concepts
    • Responsiveness
    • Color
      • List of colors
      • Color types
    • Polymorphism
  • Valence Core
    • 🏃‍♂️Fundamentals
      • 🎬The ValenceProvider
      • ✍️Using custom fonts
    • 🧱Components
      • 🔘Buttons
        • Button with icon
        • Grid Button
        • Text button
        • Icon button
        • Multi-part button
        • Unstyled button
        • Primitive button
      • ⌨️Inputs
        • Color Picker
        • Text input
        • Text area
        • Number input
        • Select input
        • Switch
        • Slider
        • Range slider
        • Pill selector
        • Input container
        • Dropdown container
      • 🖥️Display
        • Accordion
        • Alert
        • Color Swatch
        • Icon
        • Image
        • Avatar
        • Avatar Group
        • Loader
        • Pill
        • Spoiler
        • Stepper
        • Text
        • Title
      • 🧩Layout
        • App Container
        • Card
        • Flex
          • Flex Center
          • Styled Flex
        • Floating Toolbar
        • Grid
        • Header
        • Overflow Container
        • Space
      • 🗺️Navigation
        • App Nav
      • 🔼Overlays
        • Modal
        • Tooltip
        • Modal background
        • 📰Sheets
          • Bottom Sheet
          • Dynamic Sheet
          • Side Sheet
    • 🪝Hooks
      • UseColorScheme
      • UseColors
      • UseControlledList
      • UseDetectKeyDown
      • UseDisclosure
      • UseFloating
      • UseTooltip
      • UseBreakpoint
      • UseResponsiveProps
    • 🤚Generics
      • Generic button props
      • Generic input props
      • Generic Sheet Props
  • Valence Plugins
    • 🎠Valence Carousel
      • Carousel Child Props
  • Valence Utils
    • ✋Generics
      • Clickable
      • Events
      • Global
      • Grid
      • Layout
      • Overlay
      • Polymorphic
    • 🧜‍♀️Polymorphism
      • Polymorphic Button
      • Polymorphic Layout
      • Polymorphic Text
  • Update Notes
    • 3.0.0
    • 2.7.0
    • 2.6.0
    • 2.5.0
    • 2.4.0
    • 2.3.0
    • 2.2.0
    • 2.1.0
    • 2.0.0
Powered by GitBook
On this page
  • Usage
  • Custom options
  • Props
  • SelectInputEventProps

Was this helpful?

Edit on GitHub
  1. Valence Core
  2. Components
  3. Inputs

Select input

Last updated: 2.0.0 (18/01/2024)

Usage

import { SelectInput, Option } from "@valence-ui/core";

function MyComponent() { 
    const [value, setValue] = React.useState<Option | null>("option1");

    return ( 
        <SelectInput
            value={value}
            setValue={setValue}
            options={[
                "option1",
                "option2",
                "option3"
            ]}
        />
    )
}

Custom options

The Option type is a composite type that will accept a string (as shown above), or an object that includes a label, value and icon, of which value is required:

import { SelectInput, Option } from "@valence-ui/core";

function MyComponent() { 
    const [value, setValue] = React.useState<Option | null>("option1");

    return ( 
        <SelectInput
            value={value}
            setValue={setValue}
            options={[
                "option1",
                { value: "option2", label: "Option 2" },
                "option3"
            ]}
        />
    )
}

Here, "Option 2" will be displayed instead of "option2", allowing you to map value to readable strings.

import { SelectInput, Option } from "@valence-ui/core";
import { IconCloud } from "@tabler/react-icons";

function MyComponent() { 
    const [value, setValue] = React.useState<Option | null>("option1");

    return ( 
        <SelectInput
            value={value}
            setValue={setValue}
            options={[
                "option1",
                { value: "option2", icon: <IconCloud /> },
                "option3"
            ]}
        />
    )
}

Here, the IconCloud will be displayed to the left of the option in the dropdown, and the input will use that icon if option2 is selected. If the option is selected, the icon will be replaced with a check icon in the dropdown.


Props

Property
Type
Description

options (required)

Option[]

A list of options to supply for the content of this input.

icon

ReactNode

An icon to display at the left side of this input.

placeholder

string

The placeholder text to display when this input is empty.

actionicon

ReactNode

An icon to display at the right side of this input.

grow

boolean

Shorthand for flex-grow = 1.

dropdownStyle

CSSProperties

Optional styles to apply to the dropdown container.

SelectInputEventProps

Property
Type
Description

onSelect

(value: Option | null) => void

Callback to be called when an option is selected.

PreviousNumber inputNextSwitch

Last updated 1 year ago

Was this helpful?

Extends and SelectInputEventProps.

Extends .

🧱
⌨️
GenericInputProps<Option | null>
GenericTextInputEventProps