arc1/selectkit

SelectKit

A composable select component built on Radix UI primitives and Shadcn/UI components. Supports both static and dynamic data with built-in search, loading states, and accessibility.

Installation

npx shadcn@latest add https://selectkit.arc1.io/r/selectkit.json

Anatomy

import {
  SelectKit,
  SelectKitTrigger,
  SelectKitValue,
  SelectKitContent,
  SelectKitSearch,
  SelectKitList,
  SelectKitItem,
  SelectKitGroup,
  SelectKitSeparator,
  SelectKitClear,
  SelectKitLoading,
  SelectKitError,
  SelectKitEmpty,
  SelectKitLoadMore,
} from "@/components/ui/selectkit";

export default () => (
  <SelectKit>
    <SelectKitTrigger>
      <SelectKitValue />
      <SelectKitClear />
    </SelectKitTrigger>
    <SelectKitContent>
      <SelectKitSearch />
      <SelectKitList>
        <SelectKitGroup>
          <SelectKitItem />
        </SelectKitGroup>
        <SelectKitSeparator />
        <SelectKitLoading />
        <SelectKitError />
        <SelectKitEmpty />
        <SelectKitLoadMore />
      </SelectKitList>
    </SelectKitContent>
  </SelectKit>
);

API Reference

SelectKit

Contains all the parts of a select. This component manages the open state and selected value.

Props

PropTypeDefault
valuestringundefined
onValueChange(value: string) => voidundefined
defaultValuestring""
openbooleanundefined
onOpenChange(open: boolean) => voidundefined
childrenReactNode

Data attribute: [data-state] - "open" | "closed"

SelectKitTrigger

The button that toggles the select. Extends all PopoverTrigger props.

Props

PropTypeDefault
asChildbooleanfalse
disabledbooleanfalse

Data attribute: [data-state] - "open" | "closed"

SelectKitValue

The part that reflects the selected value. Automatically displays content from the selected item.

Props

PropTypeDefault
placeholderstring"Select an option..."
childrenReactNodeundefined

SelectKitContent

The component that pops out when the select is open. Extends all PopoverContent props.

Props

PropTypeDefault
asChildbooleanfalse

Data attribute: [data-state] - "open" | "closed"

SelectKitSearch

An input field for filtering options.

Props

PropTypeDefault
placeholderstring"Search..."
searchQuerystringundefined
onSearchChange(query: string) => voidundefined
debounceDelaynumber300
useDefaultFilterbooleantrue

SelectKitList

Contains the selectable items.

Props

PropTypeDefault
childrenReactNode

SelectKitItem

The component that contains the select items.

Props

PropTypeDefault
valuestring
disabledbooleanfalse
onSelect(value: string) => voidundefined
childrenReactNode

Data attribute: [data-selected] - Present when selected

SelectKitGroup

Used to group multiple items. Use in conjunction with SelectKitGroup.heading to ensure good accessibility via automatic labelling.

Props

PropTypeDefault
headingstringundefined
childrenReactNode

SelectKitSeparator

Used to visually separate items in the select.

SelectKitClear

A button to clear the current selection. Only renders when a value is selected.

Props

PropTypeDefault
childrenReactNodeundefined

SelectKitLoading

Renders a loading indicator.

Props

PropTypeDefault
childrenReactNodeDefault loading UI

SelectKitError

Renders an error message with optional retry functionality.

Props

PropTypeDefault
onRetry() => voidundefined
childrenReactNode

SelectKitEmpty

Renders when no items are available. Automatically detects search context.

Props

PropTypeDefault
searchQuerystringundefined
childrenReactNodeContextual message

SelectKitLoadMore

A button for loading additional items.

Props

PropTypeDefault
onLoadMore() => voidundefined
disabledbooleanfalse
asChildbooleanfalse
childrenReactNode"Load more..."

Keyboard Interactions

KeyDescription
SpaceWhen focus is on trigger, opens/closes the select
EnterWhen focus is on trigger, opens/closes the select
ArrowDownWhen focus is on trigger, opens select and moves focus to first item
ArrowUpWhen focus is on trigger, opens select and moves focus to last item
ArrowDownWhen focus is in content, moves focus to next item
ArrowUpWhen focus is in content, moves focus to previous item
EnterWhen focus is on item, selects item and closes
EscapeCloses select and moves focus to trigger