Select

Select component that allows users to select a single option from a list of options.

Design system docs Examples Default select field
<dap-ds-select label="Select a fruit">
<dap-ds-option-item value="item0">
  Apple
</dap-ds-option-item>
<dap-ds-option-item value="item1">Pear</dap-ds-option-item>
<dap-ds-option-item value="item2">Peach</dap-ds-option-item>
<dap-ds-option-item value="item3" disabled>Cherry</dap-ds-option-item>
<dap-ds-option-item value="item4">
  <dap-ds-icon-home-6-line slot="prefix"></dap-ds-icon-home-6-line>
  Strawberry
</dap-ds-option-item>
</dap-ds-select>
Sizes

Select component comes in three sizes: small, large. The default size is small.

<dap-ds-stack>
<dap-ds-select
size="xs"
label="Select an extra small fruit"
description="This is an extra small select field"
feedback="This is a feedback message"
feedbacktype="negative"
>
<dap-ds-option-item value="item0">
  Apple
</dap-ds-option-item>
<dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>

<dap-ds-select
label="Select a small fruit"
description="This is a small select field"
feedback="This is a feedback message"
feedbacktype="negative"
>
<dap-ds-option-item value="item0">
  Apple
</dap-ds-option-item>
<dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>

<dap-ds-select
size="lg"
label="Select a large fruit"
description="This is an large select field"
feedback="This is a feedback message"
feedbacktype="negative"
>
<dap-ds-option-item value="item0">
  Apple
</dap-ds-option-item>
<dap-ds-option-item value="item1">Pear</dap-ds-option-item></dap-ds-select>
</dap-ds-stack>
Statuses

The select component can have a status of error, success, disabled, loading.

<>
<dap-ds-select
status="error"
label="Wrong fruits">
<dap-ds-option-item value="item0">
  Apple
</dap-ds-option-item>
<dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>

<dap-ds-select
status="success"
label="Good fruits">
<dap-ds-option-item value="item0">
  Apple
</dap-ds-option-item>
<dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>

<dap-ds-select
disabled
label="Do not select fruits">
<dap-ds-option-item value="item0">
  Apple
</dap-ds-option-item>
<dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>

<dap-ds-select
loading
label="Fruits are loading">
<dap-ds-option-item value="item0">
  Apple
</dap-ds-option-item>
<dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>
</>
Custom indicator icon
<dap-ds-select label="Select a fruit" style={{ "--dds-select-icon-opened-transform": "rotate(180deg)" }}>
  <dap-ds-icon-arrow-down-s-line slot="indicator-icon"></dap-ds-icon-arrow-down-s-line>
  <dap-ds-option-item value="item0">
    Apple
  </dap-ds-option-item>
</dap-ds-select>
Custom Styling

The select component supports extensive customization beyond the default variants. This section demonstrates practical styling techniques and advanced customization patterns.

Quick Customization with CSS Custom Properties

For simple customizations, use CSS custom properties directly on the component:

<dap-ds-stack>
<dap-ds-select 
  label="Custom Colors"
  style={{
    '--dds-select-border-color': 'var(--dds-brand-600)',
    '--dds-select-bg-color': 'var(--dds-brand-50)',
    '--dds-select-text-color': 'var(--dds-brand-900)',
  }}>
  <dap-ds-option-item value="item0">Apple</dap-ds-option-item>
  <dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>

<dap-ds-select 
  label="Rounded Border"
  style={{
    '--dds-select-border-radius': 'var(--dds-radius-large)',
    '--dds-select-padding': 'var(--dds-spacing-400)',
  }}>
  <dap-ds-option-item value="item0">Apple</dap-ds-option-item>
  <dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>

<dap-ds-select 
  label="Custom Icon Transform"
  style={{
    '--dds-select-icon-opened-transform': 'rotate(180deg)',
    '--dds-select-icon-color': 'var(--dds-brand-600)',
  }}>
  <dap-ds-option-item value="item0">Apple</dap-ds-option-item>
  <dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>
</dap-ds-stack>
Theme-Aware Styling

Create select fields that automatically adapt to different themes:

<dap-ds-stack>
<dap-ds-select 
  label="High Contrast"
  style={{
    '--dds-select-border-color': 'var(--dds-border-neutral-strong)',
    '--dds-select-bg-color': 'var(--dds-background-neutral-strong)',
    '--dds-select-text-color': 'var(--dds-text-neutral-inverted)',
  }}>
  <dap-ds-option-item value="item0">Apple</dap-ds-option-item>
  <dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>

<dap-ds-select 
  label="Outlined Style"
  style={{
    '--dds-select-bg-color': 'transparent',
    '--dds-select-border-color': 'var(--dds-brand-600)',
    '--dds-select-text-color': 'var(--dds-brand-600)',
  }}>
  <dap-ds-option-item value="item0">Apple</dap-ds-option-item>
  <dap-ds-option-item value="item1">Pear</dap-ds-option-item>
</dap-ds-select>
</dap-ds-stack>
Advanced CSS Classes

For more complex styling, use CSS classes that work with the component's CSS parts. Experiment with custom select styling using CSS parts and custom properties. Try the presets below or create your own styles:

Neon styleEnhanced Option Hover
☀️ Light🌙 Dark
CopyFormatReset
CSS Editor
Live Preview

Apple

Pear Fresh

Peach
Importing
import { DapDSSelect } from 'dap-design-system'
Importing React
import { DapDSSelectReact } from 'dap-design-system/react'
Tree-Shakeable Imports

For optimal bundle sizes, use the tree-shakeable import syntax:

import { DapDSSelect } from 'dap-design-system/components'
Attributes
PropertyTypeDefaultDescription
placement'top', 'top-start' , 'top-end' , 'right' , 'right-start', 'right-end' , 'bottom' , 'bottom-start' , 'bottom-end' , 'left' , 'left-start' , 'left-end''bottom-start'The popup placement of the select
openedbooleanfalseWhether the select dropdown is opened.
placeholderstring, nullThe placeholder of the select.
syncboolean, undefinedThe sync size of the select dropdown
isMobileboolean, undefinedfalseWhether the select is in mobile mode.
loadingboolean, undefinedfalseThe loading state of the select.
maxHeightnumber, undefinedThe max heigth of the select dropdown.
noAnimationboolean, undefinedfalseWhether the select dropdown indicator is animated or not
floatingStrategy'absolute', 'fixed''absolute'The floating strategy of the select dropdown
valuestringThe value of the select.
labelstringThe label of the select.
descriptionstringThe description of the select.
tooltipstringThe tooltip of the select.
tooltipPlacement'top', 'right' , 'bottom' , 'left'The tooltip placement of the select.
size'xs', 'sm' , 'lg'The size of the select. Default is sm.
disabledbooleanWhether the select is disabled.
requiredbooleanWhether the select is required.
readonlybooleanWhether the select is readonly.
autofocusbooleanWhether the select is autofocus.
feedbackstringThe feedback of the select.
feedbackTypenegative, positive , warningThe feedback type of the select. Can be negative, positive, or warning.
statusstringThe status of the select. Can be success or error.
optionalbooleanThe optional state of the select.
optionalLabelstringThe optional label of the select.
subtlebooleanThe weight of the label. Default is false
Slots
NameDescription
(default)The option list of the select.
indicator-iconThe indicator icon of the select.
Events
Event NameDescriptionType
dds-changeFired when the select value changes.{value: string }
dds-blurEmitted when the select loses focus.{void }
dds-focusEmitted when the select gains focus.{void }
dds-openedEmitted when the select dropdown is opened.{void }
dds-closedEmitted when the select dropdown is closed.{void }
CSS Parts
Part NameDescription
baseThe main select container.
triggerThe trigger button of the select.
labelThe label of the select.
descriptionThe description of the select.
feedbackThe feedback of the select.
tooltipThe tooltip of the select.
popup-baseThe base of the popup.
option-listThe option list of the select.
option-itemThe option item of the select.
option-item-baseThe base of the option item.
option-item-labelThe label of the option item.
option-item-prefixThe prefix of the option item.
option-item-suffixThe suffix of the option item.
indicator-iconThe indicator icon of the select.
mobile-trayThe mobile tray of the select.
mobile-contentThe mobile content of the select.
mobile-bodyThe mobile body of the select.
mobile-headerThe mobile header of the select.
mobile-footerThe mobile footer of the select.
How to Use CSS Parts

You can style CSS parts using the ::part() pseudo-element selector:

/* Target a specific part */
.my-custom-dap-ds-select::part(base) {
  /* Your custom styles */
}

/* Target multiple parts */
.my-custom-dap-ds-select::part(base),
.my-custom-dap-ds-select::part(trigger) {
  /* Shared styles */
}

Example usage:

<dap-ds-select class="my-custom-dap-ds-select">
  Select
</dap-ds-select>
.my-custom-dap-ds-select::part(base) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.

CSS Custom Properties
Property NameDescription
--dds-select-min-heightMinimum height of the select component (default: var(--dds-spacing-1000))
--dds-select-paddingPadding of the select component (default: var(--dds-spacing-300))
--dds-select-column-gapColumn gap of the select component (default: var(--dds-spacing-100))
--dds-select-border-colorBorder color of the select component (default: var(--dds-border-neutral-base))
--dds-select-border-radiusBorder radius of the select component (default: var(--dds-radius-base))
--dds-select-bg-colorBackground color of the select component (default: var(--dds-background-neutral-subtle))
--dds-select-text-colorText color of the select component (default: var(--dds-text-neutral-base))
--dds-select-icon-rightRight position of the icon (default: var(--dds-spacing-200))
--dds-select-icon-colorColor of the icon (default: var(--dds-icon-neutral-subtle))
--dds-select-text-margin-rightRight margin of the text (default: var(--dds-spacing-600))
--dds-select-disabled-border-colorBorder color when disabled (default: var(--dds-background-neutral-stronger))
--dds-select-disabled-bg-colorBackground color when disabled (default: var(--dds-background-neutral-stronger))
--dds-select-disabled-text-colorText color when disabled (default: var(--dds-text-neutral-disabled))
--dds-select-error-border-colorBorder color in error state (default: var(--dds-border-negative-base))
--dds-select-success-border-colorBorder color in success state (default: var(--dds-border-positive-base))
--dds-select-xs-min-heightMinimum height for extra small size (default: var(--dds-spacing-800))
--dds-select-xs-paddingPadding for extra small size (default: var(--dds-spacing-200))
--dds-select-xs-font-sizeFont size for extra small size (default: var(--dds-font-sm))
--dds-select-lg-min-heightMinimum height for large size (default: var(--dds-spacing-1200))
--dds-select-lg-paddingPadding for large size (default: var(--dds-spacing-400))
--dds-select-lg-font-sizeFont size for large size (default: var(--dds-font-lg))
--dds-select-lg-icon-rightRight position of the icon for large size (default: var(--dds-spacing-300))
--dds-select-lg-icon-colorColor of the icon for large size (default: var(--dds-text-icon-neutral-subtle))
--dds-select-popup-bg-colorBackground color of the popup (default: var(--dds-background-neutral-subtle))
--dds-select-icon-opened-transformTransform of the icon when the select is opened (default: rotate(90deg))
How to Use CSS Custom Properties

CSS custom properties (CSS variables) can be set directly on the component or in your stylesheet:

Method 1: Inline styles (Quick customization)

<dap-ds-select
  style="--dds-select-min-height: value; --dds-select-padding: value;">
  Select
</dap-ds-select>

Method 2: CSS classes (Reusable styles)

.my-custom-dap-ds-select {
  --dds-select-min-height: value;
  --dds-select-padding: value;
  --dds-select-column-gap: value;
}
<dap-ds-select class="my-custom-dap-ds-select">
  Select
</dap-ds-select>

Method 3: Global theme customization

/* Apply to all instances */
dap-ds-select {
  --dds-select-min-height: value;
  --dds-select-padding: value;
}

CSS custom properties inherit through the Shadow DOM, making them perfect for theming. Changes apply immediately without rebuilding.

Components Option item <dap-ds-option-item/> Attributes
PropertyTypeDefaultDescription
selectedboolean, undefinedThe selected state of the option item
selectablestring'true'Wheteher the item is selectable, whether it shows the selected icon
selectedIconPositionstring'suffix'The position of the selected icon
valueany, undefinedThe value of the option item
disabledboolean, undefinedThe disabled state of the option item
focusedboolean, undefinedThe focused state of the option item
labelstring, undefinedThe label of the option item, it can be a simplier version of an item
Slots
NameDescription
prefixThe prefix of the option item.
(default)The label of the option item.
suffixThe suffix of the option item.
Events

No custom events available.

CSS Parts
Part NameDescription
baseThe main option item container.
prefixThe prefix of the option item.
labelThe label of the option item.
suffixThe suffix of the option item.
CSS Custom Properties
Property NameDescription
--dds-option-item-padding-verticalThe vertical padding of the option item.
--dds-option-item-padding-horizontalThe horizontal padding of the option item.
--dds-option-item-border-radiusThe border radius of the option item.
--dds-option-item-colorThe text color of the option item.
--dds-option-item-hover-bgThe background color of the option item when hovered.
--dds-option-item-active-bgThe background color of the option item when active.
--dds-option-item-disabled-colorThe text color of the option item when disabled.
--dds-option-item-high-contrast-borderThe border color of the option item in high contrast mode.
--dds-option-item-selected-font-weightThe font weight of the option item when selected.
--dds-option-item-xs-font-sizeThe font size of the option item in extra small size.
--dds-option-item-lg-font-sizeThe font size of the option item in large size.
--dds-option-item-selected-icon-widthThe width of the selected icon.