Skip to content

Tailwind Theme

The Tailwind theme aligns DotSelect with Tailwind CSS design conventions, including built-in dark mode support.

Usage

CDN

html
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>

<!-- DotSelect Tailwind Theme -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dot-select@latest/dist/css/themes/tailwind.min.css">

<!-- DotSelect JS -->
<script src="https://cdn.jsdelivr.net/npm/dot-select@latest/dist/js/dot-select.min.js"></script>

npm

js
import 'dot-select/dist/css/themes/tailwind.min.css';

SCSS

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

Example

Dark Mode

The Tailwind theme supports dark mode out of the box. It responds to the dark class on the <html> element (Tailwind's class-based dark mode strategy):

html
<html class="dark">
  <body class="bg-gray-900">
  </body>
</html>

Dark mode automatically adjusts:

  • Background colors to dark grays
  • Text colors to light grays and whites
  • Border colors to dark gray tones
  • Focus rings to the configured primary color
  • Dropdown shadows for dark backgrounds
  • Selected item badges for dark contrast

Media Query Dark Mode

If you prefer Tailwind's media strategy (based on prefers-color-scheme), the theme supports that too:

scss
$ds-dark-mode-strategy: 'media'; // 'class' (default) or 'media'
@import 'dot-select/src/scss/themes/tailwind';

Tailwind Theme Variables

VariableLight ValueDark ValueDescription
$ds-primary-color#3b82f6#60a5faPrimary accent
$ds-bg-color#ffffff#1f2937Control background
$ds-text-color#111827#f9fafbText color
$ds-border-color#d1d5db#4b5563Border color
$ds-placeholder-color#9ca3af#6b7280Placeholder text
$ds-dropdown-bg#ffffff#374151Dropdown background
$ds-option-hover-bg#f3f4f6#4b5563Option hover
$ds-item-bg#eff6ff#1e3a5fSelected item bg
$ds-item-color#1e40af#93c5fdSelected item text

Customizing

Override variables before importing:

scss
$ds-primary-color: #8b5cf6;    // Violet
$ds-border-radius: 0.5rem;

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

TIP

The Tailwind theme uses Tailwind-compatible spacing (multiples of 4px), border-radius values, and color palettes, so it blends naturally with Tailwind-styled forms.

MIT Licensed