Skip to content

Dropdown Component

A customizable dropdown/select component with support for single and multiple selection, custom triggers, and flexible item rendering.

Overview

The Dropdown component provides:

  • Single and multiple item selection
  • Customizable trigger elements
  • Flexible item text and value mapping
  • Chip display for multiple selections
  • Custom placement and positioning
  • Keyboard navigation support
  • Customizable styling and behavior

When to Use

Use the Dropdown component when you need to:

  • Create custom select inputs with enhanced styling
  • Implement multi-select interfaces with chip display
  • Build custom dropdown menus with specific triggers
  • Create searchable or filterable dropdown lists
  • Implement complex selection interfaces with custom item rendering

Key Features

  • Selection Modes:

    • Single selection: Choose one item at a time
    • Multiple selection: Select multiple items with chip display
    • Toggle selection: Deselect items by clicking again
  • Trigger Options:

    • Custom trigger slot for any element
    • Default button with dropdown icon
    • triggerContent slot to replace only the inner button content
    • Configurable trigger types (click, hover)
    • Disabled state support
  • Item Management:

    • Flexible item structure with text/value mapping
    • Custom item rendering through slots
    • Selected items on top option
    • No data state handling
  • Display Features:

    • Chip display for multiple selections
    • Dynamic button text based on selection
    • Checkbox indicators for multiple mode
    • Automatic trigger/menu width matching with optional overrides via buttonWidth and width
  • Interaction:

    • Click outside to close
    • ESC key to close
    • Keyboard navigation support
    • Smooth animations and transitions
  • Customization:

    • Custom placement (top, bottom, left, right)
    • Offset configuration
    • Custom width settings
    • Flexible styling options

Props

PropTypeDefaultDescription
itemsArray[]Array of items to display
modelValueArray/String/Number/Object[]Selected value(s)
itemTextString'text'Property name for item display text
itemValueString'value'Property name for item value
multipleBooleanfalseEnable multiple selection
disabledBooleanfalseDisable the dropdown
buttonTextString'Select'Default button text
noDataTextString'No items available'Text when no items available
selectedOnTopBooleanfalseShow selected items at the top
triggerTypeString'click'Trigger type (click, hover)
placementString'bottom-start'Dropdown placement
offsetArray[0, 0.125]Offset from trigger
closeOnOutsideClickBooleantrueClose on outside click
closeOnEscBooleantrueClose on ESC key
buttonWidthString/Number'auto'Width applied to the trigger button
widthString/NumbernullCustom dropdown width

Events

EventPayloadDescription
update:modelValuevalueEmitted when selection changes
item:selectitemEmitted when item is selected
item:unselectitemEmitted when item is unselected
menu:open-Emitted when menu opens
menu:close-Emitted when menu closes

Slots

SlotPropsDescription
trigger{ isOpen, selectedItems, toggleMenu, openMenu, closeMenu }Custom trigger element
triggerContent{ props }Replace the contents of the default trigger button
item{ item, selected, toggle }Custom item rendering
no-data-Custom no data content

Methods

MethodDescription
openMenu()Open the dropdown menu
closeMenu()Close the dropdown menu
toggleMenu()Toggle the dropdown menu

API Reference →

View Code →