Select

Description

Select is a UI component used to create customizable dropdown selections. This component allows users to choose an option from a list and is designed with flexibility in mind, supporting different styles and behaviors.

Usage

Options

import { Select } from "mogora-ui";

export default function SelectDemo() {
  return (
    <Select className="w-sm">
      <Select.Trigger>Options</Select.Trigger>
      <Select.Content>
        <Select.Item value="options-1">Option 1</Select.Item>
        <Select.Item value="options-2">Option 2</Select.Item>
        <Select.Item value="options-3">Option 3</Select.Item>
        <Select.Item value="options-4">Option 4</Select.Item>
      </Select.Content>
    </Select>
  )
}

API Reference

Select

A component that provides a customizable select dropdown for users to choose from.

PropTypeDescription
childrenReactNodeElements to be rendered inside the select component.
classNamestringAdditional classes for styling.
namestringThe name attribute for the hidden input field.
valuestringThe currently selected value.
onChange(e: React.ChangeEvent<HTMLInputElement>) => voidCallback function triggered when the value changes.

Select.Trigger

The trigger component used to display the select dropdown when clicked.

PropTypeDescription
childrenReactNodeThe element that can be clicked to show the dropdown.
classNamestringAdditional classes for styling.
iconReactNode | booleanOptional icon displayed alongside the selected value. Set to `false` to disable the default icon.

Select.Content

The component that contains the displayed dropdown content.

PropTypeDescription
childrenReactNodeContent to be displayed inside the dropdown.
classNamestringAdditional classes for styling.

Select.Item

An item inside the dropdown list.

PropTypeDescription
childrenstringThe text content of the item.
valuestringThe value associated with the item.
classNamestringAdditional classes for styling.
onClick(e: React.MouseEvent<HTMLLIElement, MouseEvent>) => voidCallback function triggered when the item is clicked.