@manufosela/rich-select
A customizable rich select dropdown web component with search, keyboard navigation, and extensive styling options, built with Lit
Demo code (CodePen-ready HTML, CSS, JS)
HTML (html)
<div class="container">
<div class="demo-grid">
<!-- Basic Usage -->
<div class="demo-card">
<h2>Basic Usage</h2>
<p>Simple dropdown with arrow indicator</p>
<div class="demo-content">
<rich-select id="basic" arrow>
<rich-option value="apple">Apple</rich-option>
<rich-option value="banana">Banana</rich-option>
<rich-option value="cherry">Cherry</rich-option>
<rich-option value="date">Date</rich-option>
</rich-select>
<div class="value-display">Selected: <span id="basic-value">apple</span></div>
</div>
<div class="code-block"><rich-select arrow>
<rich-option value="apple">Apple</rich-option>
<rich-option value="banana">Banana</rich-option>
<rich-option value="cherry">Cherry</rich-option>
</rich-select></div>
</div>
<!-- With Search -->
<div class="demo-card">
<h2>With Search</h2>
<p>Searchable dropdown for long lists</p>
<div class="demo-content">
<rich-select id="search-demo" arrow search placeholder="Type to filter...">
<rich-option value="argentina">Argentina</rich-option>
<rich-option value="australia">Australia</rich-option>
<rich-option value="brazil">Brazil</rich-option>
<rich-option value="canada">Canada</rich-option>
<rich-option value="denmark">Denmark</rich-option>
<rich-option value="egypt">Egypt</rich-option>
<rich-option value="france">France</rich-option>
<rich-option value="germany">Germany</rich-option>
<rich-option value="india">India</rich-option>
<rich-option value="japan">Japan</rich-option>
<rich-option value="korea">South Korea</rich-option>
<rich-option value="mexico">Mexico</rich-option>
</rich-select>
<div class="value-display">Selected: <span id="search-demo-value">argentina</span></div>
</div>
<div class="code-block"><rich-select arrow search placeholder="Type to filter...">
<rich-option value="argentina">Argentina</rich-option>
...
</rich-select></div>
</div>
<!-- Pre-selected Value -->
<div class="demo-card">
<h2>Pre-selected Value</h2>
<p>Select with default selected option</p>
<div class="demo-content">
<rich-select id="preselected" arrow animated>
<rich-option value="small">Small</rich-option>
<rich-option value="medium" selected>Medium</rich-option>
<rich-option value="large">Large</rich-option>
<rich-option value="xlarge">X-Large</rich-option>
</rich-select>
<div class="value-display">Selected: <span id="preselected-value">medium</span></div>
</div>
<div class="code-block"><rich-select arrow animated>
<rich-option value="small">Small</rich-option>
<rich-option value="medium" selected>Medium</rich-option>
<rich-option value="large">Large</rich-option>
</rich-select></div>
</div>
<!-- Disabled Options -->
<div class="demo-card">
<h2>Disabled Options</h2>
<p>Some options can be disabled</p>
<div class="demo-content">
<rich-select id="disabled-opts" arrow>
<rich-option value="free">Free Plan</rich-option>
<rich-option value="pro">Pro Plan</rich-option>
<rich-option value="enterprise" disabled>Enterprise (Contact Sales)</rich-option>
<rich-option value="custom" disabled>Custom Plan</rich-option>
</rich-select>
<div class="value-display">Selected: <span id="disabled-opts-value">free</span></div>
</div>
<div class="code-block"><rich-select arrow>
<rich-option value="free">Free Plan</rich-option>
<rich-option value="enterprise" disabled>Enterprise</rich-option>
</rich-select></div>
</div>
<!-- Disabled Select -->
<div class="demo-card">
<h2>Disabled Select</h2>
<p>Entire select can be disabled</p>
<div class="demo-content">
<rich-select id="disabled-select" arrow disabled>
<rich-option value="opt1">Option 1</rich-option>
<rich-option value="opt2">Option 2</rich-option>
<rich-option value="opt3">Option 3</rich-option>
</rich-select>
<div class="value-display">Selected: opt1 (disabled)</div>
</div>
<div class="code-block"><rich-select arrow disabled>
<rich-option value="opt1">Option 1</rich-option>
...
</rich-select></div>
</div>
<!-- With Record for Search -->
<div class="demo-card">
<h2>Custom Search Records</h2>
<p>Use record attribute for enhanced search</p>
<div class="demo-content">
<rich-select id="records" arrow search placeholder="Try 'emoji' or 'face'...">
<rich-option value="smile" record="emoji face happy smile">Smile</rich-option>
<rich-option value="heart" record="emoji love heart">Heart</rich-option>
<rich-option value="star" record="emoji star favorite">Star</rich-option>
<rich-option value="fire" record="emoji fire hot trending">Fire</rich-option>
<rich-option value="rocket" record="emoji rocket launch ship">Rocket</rich-option>
</rich-select>
<div class="value-display">Selected: <span id="records-value">smile</span></div>
</div>
<div class="code-block"><rich-select arrow search>
<rich-option value="smile" record="emoji face happy">Smile</rich-option>
<rich-option value="heart" record="emoji love heart">Heart</rich-option>
</rich-select></div>
</div>
<!-- Dark Mode -->
<div class="demo-card">
<h2>Dark Mode</h2>
<p>Automatic dark mode with .dark class</p>
<div class="demo-content">
<div class="dark-mode-container dark">
<rich-select id="dark-mode" arrow search>
<rich-option value="dark">Dark Theme</rich-option>
<rich-option value="light">Light Theme</rich-option>
<rich-option value="system" selected>System Default</rich-option>
<rich-option value="custom">Custom Theme</rich-option>
</rich-select>
</div>
<div class="value-display">Selected: <span id="dark-mode-value">system</span></div>
</div>
<div class="code-block"><div class="dark">
<rich-select arrow search>...</rich-select>
</div></div>
</div>
<!-- Custom Styled -->
<div class="demo-card">
<h2>Custom Styling</h2>
<p>Fully customizable with CSS custom properties</p>
<div class="demo-content custom-styled">
<rich-select id="custom-styled" arrow animated>
<rich-option value="design">Design</rich-option>
<rich-option value="develop">Development</rich-option>
<rich-option value="deploy">Deployment</rich-option>
<rich-option value="monitor">Monitoring</rich-option>
</rich-select>
<div class="value-display">Selected: <span id="custom-styled-value">design</span></div>
</div>
<div class="code-block">rich-select {
--caller-background: linear-gradient(135deg, #667eea, #764ba2);
--caller-color: white;
--caller-border: none;
--caller-border-radius: 12px;
--option-active-background: #667eea;
}</div>
</div>
<!-- Event Handling -->
<div class="demo-card wide-card">
<h2>Event Handling</h2>
<p>Listen for change events to respond to selections</p>
<div class="demo-content">
<div style="display: flex; gap: 1rem; align-items: center; flex-wrap: wrap;">
<rich-select id="events" arrow name="categorySelect" style="min-width: 200px;">
<rich-option value="electronics">Electronics</rich-option>
<rich-option value="clothing">Clothing</rich-option>
<rich-option value="books">Books</rich-option>
<rich-option value="home">Home & Garden</rich-option>
<rich-option value="sports">Sports & Outdoors</rich-option>
</rich-select>
<div class="value-display" style="flex: 1;">
Event log: <span id="events-log">Waiting for selection...</span>
</div>
</div>
</div>
<div class="code-block">const select = document.querySelector('rich-select');
select.addEventListener('change', (e) => {
console.log('Selected:', e.detail.value);
console.log('Name:', e.detail.name);
});</div>
</div>
</div>
</div> CSS (css)
:root {
--bg: #0c0f14;
--bg-elevated: #141923;
--bg-panel: #171d28;
--border: #262f3f;
--text: #f4f6fb;
--text-muted: #a7b0c2;
--text-dim: #7d879b;
--accent: #ff8a3d;
--accent-strong: #ff6a00;
--accent-soft: rgba(255, 138, 61, 0.16);
--shadow: 0 20px 50px rgba(5, 8, 14, 0.45);
--radius-lg: 22px;
--radius-md: 14px;
--radius-sm: 10px;
--max-width: 1160px;
}
:root {
--bg-color: #f5f5f7;
--card-bg: #ffffff;
--text-color: #1d1d1f;
--text-muted: #86868b;
--border-color: #d2d2d7;
}
* {
box-sizing: border-box;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
header {
text-align: center;
margin-bottom: 3rem;
}
h1 {
font-size: 2.5rem;
font-weight: 600;
margin-bottom: 0.5rem;
}
.subtitle {
color: var(--text-muted);
font-size: 1.1rem;
}
.demo-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
gap: 2rem;
}
.demo-card {
background: var(--card-bg);
border-radius: 16px;
padding: 2rem;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}
.demo-card h2 {
font-size: 1.25rem;
font-weight: 600;
margin: 0 0 0.5rem 0;
}
.demo-card p {
color: var(--text-muted);
font-size: 0.9rem;
margin: 0 0 1.5rem 0;
}
.demo-content {
display: flex;
flex-direction: column;
gap: 1rem;
min-height: 80px;
}
.value-display {
padding: 0.5rem 1rem;
background: var(--bg-color);
border-radius: 8px;
font-family: 'SF Mono', Monaco, monospace;
font-size: 0.85rem;
}
.code-block {
background: #1d1d1f;
color: #f5f5f7;
padding: 1rem;
border-radius: 8px;
font-family: 'SF Mono', Monaco, monospace;
font-size: 0.75rem;
overflow-x: auto;
margin-top: 1rem;
white-space: pre-wrap;
word-break: break-word;
}
footer {
text-align: center;
margin-top: 3rem;
padding-top: 2rem;
border-top: 1px solid var(--border-color);
color: var(--text-muted);
font-size: 0.9rem;
}
footer a {
color: var(--text-color);
text-decoration: none;
}
footer a:hover {
text-decoration: underline;
}
.wide-card {
grid-column: span 2;
}
@media (max-width: 768px) {
.wide-card {
grid-column: span 1;
}
.demo-grid {
grid-template-columns: 1fr;
}
}
/* Dark mode demo container */
.dark-mode-container {
background: #1f2937;
padding: 1.5rem;
border-radius: 12px;
}
.dark-mode-container.dark {
color: #e5e7eb;
}
/* Custom styled select */
.custom-styled rich-select {
--rich-select-width: 100%;
--caller-background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
--caller-color: white;
--caller-border: none;
--caller-border-radius: 12px;
--caller-padding: 12px 16px;
--arrow-color: white;
--option-active-background: #667eea;
--selectOptions-border-radius: 12px;
}
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap');
:root {
--bg: #f5f5f7;
--bg-2: #ffffff;
--bg-spot-1: #f8e9d0;
--bg-spot-2: #e8eef8;
--card: #ffffff;
--text: #1d1d1f;
--muted: #6b7280;
--line: #e5e7eb;
--accent: #ffb000;
--accent-2: #00a7d6;
--accent-soft: rgba(255, 176, 0, 0.18);
--surface-1: #f3f4f6;
--surface-2: #eef2f7;
--code-bg: #111827;
--code-text: #f9fafb;
--panel-bg: rgba(255, 255, 255, 0.85);
--overlay-bg: rgba(255, 255, 255, 0.98);
}
:root.dark {
--bg: #0f1117;
--bg-2: #151a26;
--bg-spot-1: #1a2136;
--bg-spot-2: #1d1b34;
--card: #1c2233;
--text: #f3f6ff;
--muted: #b8c0d9;
--line: #2b3247;
--accent: #ffb000;
--accent-2: #00d0ff;
--accent-soft: rgba(255, 176, 0, 0.25);
--surface-1: #0b0f1a;
--surface-2: #263046;
--code-bg: #0b0f1a;
--code-text: #d6d9e6;
--panel-bg: rgba(28, 34, 51, 0.8);
--overlay-bg: rgba(15, 17, 23, 0.98);
}
* {
box-sizing: border-box;
}
a {
color: var(--accent);
}
h1 {
color: var(--accent);
}
.demo-links {
margin-top: 12px;
display: flex;
gap: 12px;
justify-content: center;
flex-wrap: wrap;
}
.demo-links a {
border: 1px solid var(--line);
border-radius: 999px;
padding: 6px 12px;
color: var(--muted);
text-decoration: none;
font-size: 0.85rem;
transition: border-color 0.2s ease, color 0.2s ease;
}
.demo-links a:hover {
color: var(--text);
border-color: var(--accent-2);
}
.demo-theme-toggle {
margin-top: 12px;
display: flex;
justify-content: center;
}
header {
border-bottom: 1px solid var(--line);
}
.demo-card,
.section,
.demo-section,
.panel,
.card {
background: var(--card);
border: 1px solid var(--line);
border-radius: 16px;
color: var(--text);
box-shadow: 0 18px 36px rgba(6, 10, 24, 0.45);
}
.demo-card {
display: flex;
flex-direction: column;
gap: 12px;
}
.demo-card .code-block {
margin-top: auto;
}
.demo-grid,
.grid {
align-items: stretch;
}
.demo-card h2,
.demo-card h3,
.section h2,
.demo-section h2,
.panel-header {
color: var(--text);
}
.label,
.stat-label,
.category-title,
.subtitle,
.hint,
.note {
color: var(--muted);
}
.info-item,
.capability,
.preference,
.option-group,
.output,
.current-url,
.event-log,
.result-card,
.log,
.stat {
background: var(--surface-1);
border: 1px solid var(--line);
color: var(--text);
}
.info-item .label,
.capability .name {
color: var(--muted);
}
.panel-header,
.options,
.topbar,
.top-links {
background: var(--panel-bg);
border-bottom: 1px solid var(--line);
color: var(--text);
}
.subtitle,
.hint,
.note,
.demo-card p,
.section p,
.demo-section p {
color: var(--muted);
}
.code-block,
pre,
code {
background: var(--code-bg);
color: var(--code-text);
border-radius: 8px;
}
.value-display,
.output,
.result,
.demo-output {
background: var(--surface-1);
border: 1px solid var(--line);
color: var(--text);
}
button {
background: linear-gradient(120deg, var(--accent), #ff6a00);
color: #111;
border: none;
}
button:hover {
filter: brightness(1.05);
}
input,
select,
textarea {
background: var(--surface-1);
color: var(--text);
border: 1px solid var(--line);
}
footer {
color: var(--muted);
}
footer a {
color: var(--text);
}
arc-slider {
--arc-slider-text-color: var(--text);
--arc-slider-value-bg: var(--surface-1);
--arc-slider-value-border: var(--line);
--arc-slider-value-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
rich-select {
--caller-background: var(--card);
--caller-color: var(--text);
--caller-border: 1px solid var(--line);
--caller-hover-background: var(--surface-2);
--caller-hover-color: var(--text);
--caller-hover-border-color: var(--line);
--caller-focus-border-color: var(--accent-2);
--caller-focus-shadow: 0 0 0 3px rgba(0, 208, 255, 0.25);
--caller-disabled-background: var(--surface-1);
--caller-disabled-color: #6b7280;
--caller-disabled-border-color: var(--line);
--arrow-color: var(--muted);
--selectOptions-background: var(--card);
--selectOptions-border: 1px solid var(--line);
--selectOptions-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
--input-background: var(--surface-1);
--input-border: 1px solid var(--line);
--input-color: var(--text);
--input-placeholder-color: #6b7280;
--option-color: var(--text);
--option-hover-background: var(--surface-2);
--option-hover-color: var(--text);
--option-active-background: var(--accent);
--option-active-color: #111;
--option-selected-background: var(--accent-soft);
--option-selected-color: var(--text);
--option-disabled-background: var(--surface-1);
--option-disabled-color: #6b7280;
}
multi-select {
--multi-select-bg: var(--card);
--multi-select-border-color: var(--line);
--multi-select-border-hover: var(--line);
--multi-select-border-focus: var(--accent-2);
--multi-select-text-color: var(--text);
--multi-select-placeholder-color: #6b7280;
--multi-select-arrow-color: var(--muted);
--multi-select-dropdown-bg: var(--card);
--multi-select-shadow: 0 10px 22px rgba(0, 0, 0, 0.45);
--multi-select-option-hover-bg: var(--surface-2);
--multi-select-option-selected-bg: var(--accent-soft);
}
tab-nav {
--tab-bg: var(--card);
--tab-border: var(--line);
--tab-text: var(--muted);
--tab-active-text: var(--text);
--tab-hover-bg: var(--surface-2);
--tab-active-border: var(--accent);
--tab-disabled: #9ca3af;
}
slider-underline {
--slider-track: var(--surface-2);
--slider-fill: var(--accent);
--slider-thumb: var(--accent);
--slider-label-color: var(--text);
--slider-tick-color: #9ca3af;
--slider-tick-value-color: var(--muted);
}
header-nav {
--header-bg: var(--card);
--header-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
--header-link-color: var(--text);
--header-link-hover: var(--accent);
--header-mobile-hover-bg: var(--surface-2);
}
calendar-inline {
--calendar-bg: var(--card);
--calendar-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
--calendar-text: var(--text);
--calendar-accent: var(--accent);
--calendar-today: var(--accent-soft);
--calendar-selected: var(--accent);
--calendar-hover-bg: var(--surface-2);
--calendar-muted: var(--muted);
--calendar-muted-strong: #9ca3af;
--calendar-other-month: #9ca3af;
--calendar-disabled: #cbd5e1;
--calendar-holiday: #ef4444;
--calendar-holiday-selected: #111;
}
marked-calendar {
--calendar-bg: var(--card);
--calendar-border: var(--line);
--calendar-title: var(--text);
--calendar-muted: var(--muted);
--calendar-surface: var(--surface-1);
--calendar-accent: var(--accent);
--calendar-accent-hover: #ff7a1a;
--calendar-border-strong: var(--line);
--calendar-contrast: #111;
--calendar-nav-bg: var(--surface-1);
--calendar-nav-hover: var(--surface-2);
}
radar-chart {
--radar-bg: var(--card);
--radar-grid-color: var(--line);
--radar-axis-color: #94a3b8;
--radar-label-color: var(--muted);
}
multi-carousel {
--carousel-bg: var(--card);
--carousel-arrow-bg: var(--surface-1);
--carousel-arrow-color: var(--text);
--carousel-arrow-hover-bg: var(--surface-2);
--carousel-arrow-hover-color: var(--text);
--carousel-nav-bg: var(--surface-1);
--carousel-nav-color: var(--muted);
--carousel-nav-hover: #9ca3af;
--carousel-nav-active: var(--accent);
--carousel-focus-color: var(--accent-2);
}
nav-list {
--nav-list-bg: var(--card);
--nav-list-border-color: var(--line);
--nav-list-selected-border-color: var(--accent);
--nav-list-selected-bg: var(--surface-2);
--nav-list-hover-bg: var(--surface-2);
--nav-list-selected-color: var(--text);
}
theme-toggle {
--theme-toggle-bg: var(--card);
--theme-toggle-icon-color: var(--muted);
--theme-toggle-hover-bg: var(--surface-2);
--theme-toggle-active-bg: var(--surface-1);
--theme-toggle-active-color: var(--text);
--theme-toggle-dark-bg: var(--card);
--theme-toggle-dark-border: var(--line);
--theme-toggle-dark-icon-color: var(--muted);
--theme-toggle-dark-active-bg: var(--surface-1);
--theme-toggle-dark-active-color: var(--text);
--theme-toggle-dark-hover-bg: var(--surface-2);
}
qr-code {
--qr-fg: #0f1117;
--qr-bg: #f3f6ff;
}
click-clock {
--clock-color: var(--text);
--clock-bg: var(--card);
--clock-muted-color: var(--muted);
}
historical-line {
--title-color: var(--text);
--border-color: var(--line);
--year-bg: var(--surface-1);
}
circle-steps {
--steps-muted: var(--muted);
--steps-text: var(--text);
--steps-pending: var(--surface-2);
}
rich-inputfile {
--input-border: var(--line);
--input-border-focus: var(--accent-2);
--input-bg: var(--card);
--input-label-color: var(--text);
--input-hover-bg: var(--surface-2);
--input-drag-bg: var(--accent-soft);
--input-disabled-bg: var(--surface-1);
--input-success-border: #22c55e;
--input-success-bg: rgba(34, 197, 94, 0.12);
--input-icon-color: #94a3b8;
--input-text-color: var(--muted);
--input-accent-color: var(--accent-2);
--input-file-bg: var(--surface-1);
--input-preview-bg: var(--surface-1);
--input-file-name-color: var(--text);
--input-file-size-color: var(--muted);
--input-error-color: #ef4444;
--input-hint-color: var(--muted);
}
data-card {
--data-card-bg: var(--card);
--data-card-border-color: var(--line);
--data-card-title-color: var(--text);
--data-card-desc-color: var(--muted);
--data-card-info-bg: var(--overlay-bg);
--data-card-info-close-bg: var(--surface-2);
--data-card-info-close-color: var(--text);
--data-card-info-close-hover-bg: var(--surface-1);
--data-card-info-text: var(--text);
--data-card-loading-color: var(--muted);
--data-card-info-trigger-hover: var(--accent);
}
app-modal {
--app-modal-bg: var(--card);
--app-modal-body-color: var(--text);
--app-modal-standalone-bg: rgba(255, 176, 0, 0.35);
--app-modal-standalone-color: #111;
--app-modal-standalone-hover-bg: rgba(255, 176, 0, 0.6);
} JS (js)
document.querySelectorAll('.footer-year').forEach(el => el.textContent = new Date().getFullYear());
import "https://esm.sh/@manufosela/rich-select";
// Helper to update value displays
function setupValueDisplay(id) {
const select = document.getElementById(id);
const display = document.getElementById(`${id}-value`);
if (select && display) {
select.addEventListener('change', (e) => {
display.textContent = e.detail.value;
});
}
}
// Setup all value displays
['basic', 'search-demo', 'preselected', 'disabled-opts', 'records', 'dark-mode', 'custom-styled'].forEach(setupValueDisplay);
// Events demo with detailed logging
const eventsSelect = document.getElementById('events');
const eventsLog = document.getElementById('events-log');
if (eventsSelect && eventsLog) {
eventsSelect.addEventListener('change', (e) => {
const timestamp = new Date().toLocaleTimeString();
eventsLog.textContent = `[${timestamp}] name="${e.detail.name}", value="${e.detail.value}"`;
});
}
import '../../theme-toggle/src/theme-toggle.js';
const root = document.documentElement;
root.classList.add('dark');
const toggle = document.querySelector('theme-toggle');
if (toggle) {
toggle.theme = root.classList.contains('dark') ? 'dark' : 'light';
toggle.addEventListener('theme-changed', (event) => {
const theme = event.detail?.theme;
if (!theme) return;
root.classList.toggle('dark', theme === 'dark');
});
}