Skip to content

Custom Theme

Build a fully custom DotSelect theme by overriding SCSS variables and adding your own styles.

Quick Start

Create a custom theme by overriding variables before importing DotSelect's base styles:

scss
// my-theme.scss

// 1. Override variables
$ds-primary-color: #8b5cf6;
$ds-border-radius: 12px;
$ds-font-family: 'Inter', sans-serif;
$ds-font-size: 0.9rem;
$ds-border-color: #e2e8f0;
$ds-item-bg: #f5f3ff;
$ds-item-color: #6d28d9;
$ds-item-border: #c4b5fd;

// 2. Import the base theme
@import 'dot-select/src/scss/themes/default';

// 3. Add your own overrides (optional)
.dot-select {
  .ds-control {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }
}

Compile with your SCSS toolchain and include the resulting CSS.

Full Variable Reference

Layout & Sizing

VariableDefaultDescription
$ds-font-familysystem-ui, -apple-system, sans-serifFont stack for all text
$ds-font-size0.875remBase font size
$ds-font-size-sm0.8remFont size for sm variant
$ds-font-size-lg1remFont size for lg variant
$ds-line-height1.5Base line height
$ds-min-height38pxMinimum height of the control
$ds-min-height-sm32pxMinimum height for sm variant
$ds-min-height-lg46pxMinimum height for lg variant
$ds-padding-x12pxHorizontal padding inside the control
$ds-padding-y6pxVertical padding inside the control

Colors

VariableDefaultDescription
$ds-primary-color#3b82f6Primary accent color
$ds-bg-color#ffffffControl background
$ds-text-color#1f2937Primary text color
$ds-placeholder-color#9ca3afPlaceholder text color
$ds-border-color#d1d5dbBorder color
$ds-hover-border-color#9ca3afBorder color on hover
$ds-disabled-opacity0.5Opacity for disabled state
$ds-disabled-bg#f9fafbBackground for disabled state

Focus

VariableDefaultDescription
$ds-focus-border-color$ds-primary-colorBorder color when focused
$ds-focus-ring-colorrgba($ds-primary-color, 0.25)Focus ring color
$ds-focus-ring-width3pxFocus ring width

Borders

VariableDefaultDescription
$ds-border-width1pxBorder width
$ds-border-radius6pxBorder radius
$ds-border-radius-sm4pxBorder radius for sm variant
$ds-border-radius-lg8pxBorder radius for lg variant
VariableDefaultDescription
$ds-dropdown-bg#ffffffDropdown background
$ds-dropdown-border-color$ds-border-colorDropdown border color
$ds-dropdown-border-width1pxDropdown border width
$ds-dropdown-border-radius$ds-border-radiusDropdown border radius
$ds-dropdown-shadow0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1)Dropdown shadow
$ds-dropdown-max-height300pxMaximum dropdown height
$ds-dropdown-z-index1050Dropdown z-index

Options

VariableDefaultDescription
$ds-option-padding-x12pxOption horizontal padding
$ds-option-padding-y8pxOption vertical padding
$ds-option-hover-bg#f3f4f6Option hover background
$ds-option-hover-color$ds-text-colorOption hover text color
$ds-option-selected-bg#eff6ffSelected option background
$ds-option-selected-color$ds-primary-colorSelected option text color
$ds-option-disabled-color#d1d5dbDisabled option text color
$ds-optgroup-label-color#6b7280Optgroup heading color
$ds-optgroup-label-size0.75remOptgroup heading font size

Selected Items (Tags/Badges)

VariableDefaultDescription
$ds-item-bg#eff6ffItem badge background
$ds-item-color#1e40afItem badge text color
$ds-item-border#bfdbfeItem badge border color
$ds-item-border-width1pxItem badge border width
$ds-item-border-radius4pxItem badge border radius
$ds-item-padding-x8pxItem horizontal padding
$ds-item-padding-y2pxItem vertical padding
$ds-item-font-size0.8remItem font size
$ds-item-gap4pxGap between items

Search Input

VariableDefaultDescription
$ds-search-padding8px 12pxSearch input padding
$ds-search-border-color$ds-border-colorSearch input border color
$ds-search-bg#ffffffSearch input background

Icons

VariableDefaultDescription
$ds-arrow-color#6b7280Dropdown arrow color
$ds-arrow-size20pxArrow icon size
$ds-clear-color#9ca3afClear button color
$ds-clear-hover-color#ef4444Clear button hover color
$ds-remove-color#9ca3afRemove button color
$ds-remove-hover-color#ef4444Remove button hover color

Transitions

VariableDefaultDescription
$ds-transition-speed150msTransition duration
$ds-transition-fnease-in-outTransition timing function

Example: Brand Theme

A complete example creating a branded theme:

scss
// brand-theme.scss
$ds-primary-color: #f97316;        // Orange
$ds-font-family: 'Poppins', sans-serif;
$ds-border-radius: 10px;
$ds-border-color: #fed7aa;
$ds-hover-border-color: #fb923c;
$ds-focus-ring-color: rgba(249, 115, 22, 0.2);
$ds-item-bg: #fff7ed;
$ds-item-color: #c2410c;
$ds-item-border: #fdba74;
$ds-item-border-radius: 10px;
$ds-dropdown-shadow: 0 10px 25px -5px rgba(249, 115, 22, 0.15);
$ds-option-selected-bg: #fff7ed;
$ds-option-selected-color: #ea580c;

@import 'dot-select/src/scss/themes/default';

// Extra custom styles
.dot-select .ds-control {
  font-weight: 500;
}

.dot-select .ds-dropdown-header {
  background: linear-gradient(135deg, #fff7ed, #ffedd5);
}

CSS Custom Properties

For runtime theming without SCSS, DotSelect exposes CSS custom properties:

css
:root {
  --ds-primary-color: #3b82f6;
  --ds-bg-color: #ffffff;
  --ds-text-color: #1f2937;
  --ds-border-color: #d1d5db;
  --ds-border-radius: 6px;
  --ds-font-size: 0.875rem;
  --ds-dropdown-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* Dark mode override */
.dark {
  --ds-primary-color: #60a5fa;
  --ds-bg-color: #1f2937;
  --ds-text-color: #f9fafb;
  --ds-border-color: #4b5563;
  --ds-dropdown-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

WARNING

CSS custom properties provide runtime flexibility but are limited compared to SCSS variables. Some computed values (like rgba() with opacity based on the primary color) require SCSS compilation.

MIT Licensed