webdevpuneet.com

Custom Select Dropdown in CSS: appearance base-select

Custom Select Dropdown in CSS: appearance base-select · Forms · Plain HTML, CSS & JS · Live preview

CategoryForms

About this UI Snippet

A Select You Can Finally Style: appearance base-select

Screenshot of the Custom Select Dropdown in CSS: appearance base-select snippet rendered live

The native select has resisted styling since the 1990s, so developers rebuilt it from divs, ARIA roles and a few hundred lines of script. Chrome's appearance: base-select turns that around: the select keeps its keyboard behaviour, form value and mobile picker, but its button, arrow and menu become ordinary CSS-styled elements. This snippet restyles two selects in a support form.

Opting in

Setting appearance: base-select on both select and select::picker(select) switches the control and its popup to the customisable rendering. Without it nothing changes, which is why the declaration lives on both selectors.

Real content inside options

Options can contain markup. Here each language option holds a coloured language badge, a bold name and a small response-time line, and the priority options hold a coloured dot. A <button> with <selectedcontent> as the first child of the select shows a live copy of the chosen option, with the small line hidden by CSS.

Pseudo-elements for the details

::picker-icon is the arrow, rotated while the select is :open. option::checkmark is the tick on the chosen row. The menu is a popover, so @starting-style and allow-discrete give it the same fade-and-slide used by animated dialogs.

What you keep

Typing to jump to an option, arrow keys, Escape, form submission, label association and the native sheet on phones all still work, because the element is still a select. A custom div dropdown has to re-implement each one.

Fallback

Browsers without support ignore the unknown value and render a standard select; the option markup is dropped to plain text. The script reports which you are seeing. For a searchable JS version see the combobox.

Accessibility notes

Keep text contrast high inside the menu, never rely on the coloured dot alone to carry the meaning, and keep the visible focus ring on the closed control. Because the element is still a select, screen readers announce the label, the selected option and the list size the same way they do for any select.

What's included

Features

Native select kept
Form value, typing to jump, arrow keys and Escape all work as before.
Rich options
Badges, two-line labels and coloured dots live inside the option elements.
Live selected content
selectedcontent mirrors the chosen option in the closed control.
Restylable arrow
::picker-icon rotates with the :open state.
Checkmark pseudo-element
option::checkmark marks the current choice, positioned with flex order.
Animated popup
The menu fades and slides in with @starting-style.
Safe fallback
Unsupported browsers show a standard working select.
Reduced motion
Transitions switch off under prefers-reduced-motion.

Step by step

How to Use

  1. 1
    Put a button first inside the selectWrite select > button > selectedcontent before the options. The browser fills selectedcontent with a copy of whichever option is chosen.
  2. 2
    Opt in on two selectorsSet appearance: base-select on the select and on select::picker(select). Skip the second and the menu stays the old system one.
  3. 3
    Put markup inside optionsAdd a badge or icon, a title and a small line, or a coloured dot. Hide parts you do not want in the closed button with selectedcontent .your-class.
  4. 4
    Restyle the arrow and tick::picker-icon draws the arrow (rotate it under :open) and option::checkmark draws the tick; use order and margin-left: auto to move the tick right.
  5. 5
    Animate the menuGive ::picker(select) opacity 0, then add :popover-open, @starting-style and a transition with overlay and display allow-discrete.
  6. 6
    Read the support noteThe line under the form shows whether the current browser supports base-select; if not you still get a working native select.

Real-world uses

Common Use Cases

Language and region pickers
Show a language badge, a language name and a service note in one row, in a control that still submits a normal value and opens the native sheet on phones.
Priority and status fields
Mark ticket priority or order status with coloured dots inside a dropdown that stays a real select for screen readers.
Replacing div dropdowns
Retire a custom listbox that re-implemented typeahead, focus and Escape, and keep the look with a fraction of the code.
Design-system form controls
Give a component library a themed select that follows its tokens in light and dark without a JavaScript widget per page.

Got questions?

Frequently Asked Questions

Chrome and Edge from version 135. Safari and Firefox do not support it yet and show the normal select, which is why this snippet is a progressive enhancement and not a replacement for every use.

The button is the closed, clickable part and selectedcontent inside it mirrors the chosen option. Older browsers ignore the button, so the markup degrades to a plain select with plain-text options.

It is a real select, so the role, labels, keyboard handling and form behaviour come from the browser. You are responsible for contrast, a visible focus ring and not hiding information that only lives in a coloured dot.

Yes. Options can contain images, icons and spans. Keep the closed state simple by hiding secondary parts with a selectedcontent rule, and do not put interactive elements inside an option.

Copy & paste

Source Code

<main class="bs-page">
  <h1>Style the real select</h1>
  <p class="bs-sub">Badges, descriptions and a rounded menu inside a native &lt;select&gt;. No div-based dropdown, no JavaScript.</p>

  <form class="bs-form" onsubmit="return false">
    <label class="bs-field">
      <span>Support language</span>
      <select name="lang" class="bs-select">
        <button type="button"><selectedcontent></selectedcontent></button>
        <option value="en" selected><span class="bs-flag" style="--h:215">EN</span><span class="bs-txt"><b>English</b><small>Replies within 2 hours</small></span></option>
        <option value="de"><span class="bs-flag" style="--h:350">DE</span><span class="bs-txt"><b>Deutsch</b><small>Replies within 4 hours</small></span></option>
        <option value="fr"><span class="bs-flag" style="--h:235">FR</span><span class="bs-txt"><b>Fran&ccedil;ais</b><small>Replies within 4 hours</small></span></option>
        <option value="es"><span class="bs-flag" style="--h:35">ES</span><span class="bs-txt"><b>Espa&ntilde;ol</b><small>Replies next day</small></span></option>
      </select>
    </label>

    <label class="bs-field">
      <span>Priority</span>
      <select name="prio" class="bs-select">
        <button type="button"><selectedcontent></selectedcontent></button>
        <option value="low"><i class="bs-dot" style="--c:#22c55e"></i>Low</option>
        <option value="normal" selected><i class="bs-dot" style="--c:#3b82f6"></i>Normal</option>
        <option value="high"><i class="bs-dot" style="--c:#f59e0b"></i>High</option>
        <option value="urgent"><i class="bs-dot" style="--c:#ef4444"></i>Urgent</option>
      </select>
    </label>
  </form>
  <p class="bs-note" id="bsNote"></p>
</main>

Extend with AI

Take This Snippet Further With AI

Paste this snippet into an AI coding assistant and ask it to explain why appearance: base-select must be set on both the select and its ::picker(select), and what selectedcontent does. Useful follow-ups: add an avatar to each option for a user switcher, group options with optgroup headings, or tint the menu to match dark mode. Ask it to keep the fallback note and reduced-motion support.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a customisable native select dropdown in plain HTML and CSS using appearance: base-select.

Requirements:
- A form with two labelled selects. The first lists four support languages; each option holds a coloured two-letter badge, a bold language name and a small "Replies within N hours" line. The second lists Low, Normal, High and Urgent with a coloured dot before the text.
- Markup: select > button > selectedcontent first, then the option elements.
- CSS: appearance: base-select on both .select and .select::picker(select). Style the closed control (border, radius, hover, :focus-visible ring, :open state), draw the arrow with ::picker-icon and rotate it while :open, and show a tick with option::checkmark pushed to the right.
- Style the popup: rounded, shadow, margin-top, and animate it with opacity and translate using :popover-open, @starting-style and a transition that lists overlay and display with allow-discrete.
- Hide the small description line inside the closed button with selectedcontent .small-class { display: none }.
- A script that sets a note using CSS.supports('appearance', 'base-select') to say whether the browser supports it. Respect prefers-reduced-motion and work at phone width.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.