Skip to content
Web PlatformPublished Updated 9 min read

Styling Native Form Controls in 2026: appearance: base-select, OTP Inputs, and Validation

How to keep real <select>, <input>, and form validation semantics while delivering modern dark/light control styling.

View .md

Custom JavaScript form widgets are famous for failing quietly on real devices. A custom dropdown built out of <div> elements loses type-ahead on iOS VoiceOver. Six separate <input maxlength="1"> boxes break SMS autofill and clipboard paste. A hand-rolled checkbox forgets Windows Forced Colors Mode and disappears for users with low vision.

You get cleaner accessibility—and dramatically less code—when real native <input>, <select>, and <form> elements stay in charge of state, autofill, and form submission.

Here is how Haze UI styles modern form controls without replacing HTML semantics.

Customizing native <select> with appearance: base-select

For twenty years, <select> popups resisted styling across browsers. Now appearance: base-select (combined with ::picker(select), ::checkmark, and ::picker-icon) lets CSS style the open dropdown list directly inside the top layer using the exact same design tokens as your popover menus.

Inside src/styles/haze.css, Haze UI activates this inside a progressive @supports block:

@supports (appearance: base-select) {
  select, ::picker(select) {
    appearance: base-select !important;
  }
  ::picker(select) {
    margin-block: 4px;
    padding: 4px;
    max-height: min(20rem, 60vh);
    border-radius: var(--radius-lg);
    background-color: var(--popover);
    color: var(--popover-foreground);
    box-shadow: var(--shadow-float);
    transition: opacity 150ms var(--ease-snappy),
                translate 150ms var(--ease-snappy),
                display 150ms allow-discrete,
                overlay 150ms allow-discrete;
  }
  @starting-style {
    select:open::picker(select) {
      opacity: 0;
      translate: 0 -4px;
    }
  }
}

Meanwhile, Select adds [&::picker-icon]:hidden on the <select> itself so its custom Lucide ChevronDown icon stays consistent between browsers that support base-select and those falling back to native OS menus.

Need Use this Haze UI entry Underlying DOM pattern
Standard 3–15 item form picklist Select Native <select> + base-select progressive enhancement
Searchable list with descriptions Morph Select Popover + filtered options + native form input
Country code + phone formatting Phone Input Real <select> value + searchable country popover
Six-digit MFA / SMS verification OTP Input Single one-time-code <input> + visual digit slots
Boolean toggles & switches Checkbox & Switch Native <input type="checkbox"> + forced-colors:appearance-auto

Why single-input OTP beats six separate <input> elements

Split-box OTP inputs look great in design files and feel miserable when users try to paste "482 910" from an email or tap an iOS keyboard SMS suggestion. Six independent inputs force you to manually intercept keydown, move focus on Backspace, slice pasted strings across inputs, and re-concatenate values before form submission.

OTP Input flips that architecture inside out:

  1. Without JavaScript, the user sees a clean, monospaced numeric <input id={id} name={name} autocomplete="one-time-code" inputmode="numeric" maxlength={digits}>. It works with HTML forms immediately.
  2. With progressive JS, the parent sets data-enhanced, draws six visual <span> slots (data-otp-slot) with an optional center dash (separator), and stretches the real <input> invisibly (opacity-0 inset-0) over top of the slots.

Because there is still only one real <input>:

  • Browser SMS autofill (autocomplete="one-time-code") drops all six digits straight in.
  • Selecting and deleting or pasting "48-29-10" strips non-digits cleanly and fills every slot in one pass.
  • Mouse clicks on a specific visual slot calculate the nearest slot boundary and place the caret accurately via setSelectionRange.
  • Form submission sends a single name=482910 field with zero hidden mirror inputs.

Checkboxes and switches that respect Forced Colors Mode

Custom-drawn checkboxes (appearance-none) solve dark/light visual alignment, yet introducing appearance-none creates a classic accessibility trap in Windows High Contrast / Forced Colors Mode: the custom border and background tint vanish unless you explicitly restore native OS appearance.

Look at how Checkbox and Switch prevent this:

  • Keep the real <input type="checkbox"> (with role="switch" on switches).
  • Add forced-colors:appearance-auto to the <input> class list.
  • Hide the custom SVG check/minus mark or CSS thumb using forced-colors:hidden / forced-colors:before:hidden.
  • When disabled (has-[:disabled]), dim the control box and label (opacity-50), never the helper description paragraph—keeping helper copy legible above WCAG AA contrast thresholds (4.5:1) as noted in DECISIONS.md.
---
import Checkbox from "../components/haze/ui/checkbox.astro";
import Switch from "../components/haze/ui/switch.astro";
---

<Checkbox
  id="accept-terms"
  label="Send release notes for installed components"
  description="Monthly summary only. Unsubscribe with one click."
  required
/>
<Switch
  id="single-key"
  label="Single-key keyboard shortcuts"
  description="Turn off if shortcuts conflict with assistive tools."
  checked
/>

Quiet field focus vs. error validation states

One subtle detail makes form-heavy UIs feel calm instead of jittery: in Chromium, text fields (<input>, <textarea>) match :focus-visible on mouse clicks as well as keyboard Tab presses. Putting a heavy outline-2 white ring around every text box makes clicking into a search bar look loud and boxed in.

Haze UI uses a split focus strategy verified across Input, Input Group, and Form:

  • Buttons, checkboxes, switches, and links: focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring (appears on keyboard focus only).
  • Text inputs and <select>: focus-visible:border-ring focus-visible:outline-hidden (a clean 1 px border shift with no bulky ring).
  • Composite wrappers (Input Group): has-[:is(input,textarea):focus-visible]:border-ring rather than focus-within:, so clicking an inline copy or reveal-password button inside the field wrapper doesn’t light up the entire field border!
  • Invalid state: aria-invalid:border-destructive! paired with visible error text linked via aria-describedby, plus Form for an accessible top error summary connected to native browser Constraint Validation.

Next, learn how the color math behind --input, --border-control, --ring, and dark/light surfaces stays accessible in Tailwind CSS v4 Design Tokens with OKLCH.

Frequently asked questions

What happens if a browser does not support CSS appearance: base-select yet?

Haze UI wraps base-select and ::picker(select) inside @supports (appearance: base-select) in src/styles/haze.css. Supported browsers render the custom dark or light menu recipe; other browsers automatically fall back to their reliable native OS <select> popup.

Why does Haze UI's OTP Input use one <input> instead of six separate boxes?

Rendering one transparent <input autocomplete='one-time-code' inputmode='numeric'> stretched over six styled visual slots ensures iOS/macOS SMS autofill, password manager fills, and multi-digit clipboard paste work reliably without splitting characters across separate DOM nodes.

How do custom checkboxes and switches behave in Windows High Contrast Mode?

Haze UI checkboxes and switches combine appearance-none for custom dark/light visuals with forced-colors:appearance-auto and forced-colors:hidden on decorative check icons, so Forced Colors Mode restores high-contrast system controls automatically.

When should I pick Morph Select instead of native Select?

Use native Select for short lists of options inside forms. Switch to Morph Select or Combobox when users need live type-ahead search, option descriptions, or large lists.

Components & blocks mentioned

Browse all entries
  • Native select with the same field finish as the input, a chevron over the right edge and an optional disabled placeholder option.

    npx shadcn@latest add @haze/select
  • Single-line text field with a soft border on a filled background, a muted placeholder, and a stronger border plus ring on focus.

    npx shadcn@latest add @haze/input
  • A native checkbox with a label, optional description, and a mixed state for partially selected groups.

    npx shadcn@latest add @haze/checkbox
  • On/off toggle drawn on a native checkbox with role=switch: a 36 by 20 px track and a sliding thumb, with label and description.

    npx shadcn@latest add @haze/switch
  • A row of digit slots for a fixed-length code, backed by one real numeric input for paste, autofill and screen readers.

    npx shadcn@latest add @haze/otp-input
  • A form wrapper that replaces native validation bubbles with an error summary, linked to each invalid field and its inline message.

    npx shadcn@latest add @haze/form
  • A native form select enhanced into an anchored, searchable choice panel with a moving selected label.

    npx shadcn@latest add @haze/morph-select
  • Country calling codes and a real telephone field with progressive international normalization and length feedback.

    npx shadcn@latest add @haze/phone-input

Start with one component

Try it on its page, then install it with one command.