Rokkit Logo 1.0.0-next.122

Select

Input component that allows users to choose one value from a list of options.

Introduction

Input component that allows users to choose one value from a list of options. This component has properties and behavior similar to the List component, but designed specifically for form input.

Notable features:

  • Dropdown interface for space-efficient selection
  • Field mapping to adapt to any data structure
  • Placeholder text support for empty states
  • Keyboard navigation and accessibility support
  • Custom component rendering with `using` property
  • Search and filtering capabilities

Basic Example

Here's a simple example of a Select component with placeholder text. Click to open the dropdown and select an option:

No preview available
No tabs available.

Properties

The Select component provides comprehensive properties for form integration and data adaptation.

Core Properties

  • options: Array of options to choose from
  • value: Current selected value (bindable)
  • fields: Adapt to your data by customizing field mappings
  • placeholder: Text displayed when no value is selected

Customization

  • using: Object containing components for displaying data
  • class: Custom CSS classes for styling

Here's the basic usage with string options:

Highlighting code...

Field Mapping

Like other Rokkit components, Select can adapt to your data structure using field mappings. This allows you to use objects with custom property names instead of transforming your data.

No preview available
No tabs available.

Example of field mapping with objects:

Highlighting code...

Common Field Mappings

You can map various properties to customize how your data is displayed:

  • text: The main display text
  • image: Optional image for each option
  • icon: Optional icon for each option
  • value: The actual value when selected (defaults to the object itself)

Advanced Usage

The Select component supports advanced features like custom rendering, search functionality, and complex data structures.

Search & Filtering

Enable search functionality to filter large option lists, making it easier for users to find specific items.

Custom Rendering

Use the `using` property to provide custom components for rendering options, enabling rich displays with images, badges, or complex layouts.

Ready for more?

Now that you understand how the Select component works, explore MultiSelect for multiple selections or learn about other form components.

MultiSelect → DropDown →