How to Style Pure CSS Form Controls: Custom Checkboxes, Toggles & Range Sliders

The Quick Answer

To style custom form controls in pure CSS without losing accessibility, declare appearance: none on native inputs (or position the input invisibly over a custom visual element), and use the :checked pseudo-class alongside the adjacent sibling selector (input:checked + label). For modern browsers, declare accent-color: #6c63ff for instant branded tinting with native browser keyboard navigation and screen reader semantics.

Interactive Demo Live Preview
Range Slider 75%

Step 1: Resetting Default OS Styling with appearance: none

Native inputs inherit clunky, OS-specific chrome from Windows, macOS, or iOS. Setting appearance: none strips away operating system styling, giving you a clean slate while preserving built-in keyboard navigation, accessibility tags, and form submission payloads.

form-reset.css
input[type="checkbox"],
input[type="radio"],
input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  cursor: pointer;
}

Step 2: Building Custom Checkboxes with :checked and Sibling Selectors

By hiding the native checkbox visually (while keeping it accessible to screen readers) and pairing it with a styled <label>, you can render custom SVGs, checkmarks, or colored boxes using the :checked + label selector.

custom-checkbox.css
.custom-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.custom-check input {
  position: absolute;
  opacity: 0;
  width: 1em;
  height: 1em;
}

.custom-check .box {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: var(--surface);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-check input:checked + .box {
  background: #6c63ff;
  border-color: #6c63ff;
  box-shadow: 0 0 12px rgba(108, 99, 255, 0.4);
}

Step 3: Accessible Pure CSS iOS-Style Toggle Switches (Zero JavaScript)

Toggle switches are essentially styled checkboxes. Using a container with an inner rounded thumb element, we can translate the thumb horizontally when the checkbox is checked, accompanied by a color transition on the background track.

toggle-switch.css
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.switch .slider {
  position: absolute;
  inset: 0;
  background-color: #334155;
  border-radius: 9999px;
  transition: background-color 0.3s ease;
}

.switch .slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.switch input:checked + .slider { background-color: #10b981; }
.switch input:checked + .slider::before { transform: translateX(22px); }

Step 4: Styling Cross-Browser Range Sliders

Range inputs require targeting browser-specific vendor pseudo-elements: ::-webkit-slider-thumb for Chromium/Safari and ::-moz-range-thumb for Firefox. Always define both separately to prevent CSS parsing drops.

range-slider.css
input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
  cursor: pointer;
  transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

Next-Level Addons: Elevating Your Implementation

Take this technique further by combining it with complementary design token studios and animation tools:

1. Multi-Pass Focus Rings & Offset Outlines

Explore in Border & Ring Studio →

Ground custom form controls with accessible double focus rings using outline-offset and ambient glow shadows.

Input Required ↑
Email Address

2. Form Validation Tooltip Bubble Anchoring

Explore in Tooltips & Popovers Studio →

Anchor real-time validation error alerts and password requirement tooltips directly to input elements using pure CSS.

3. Wide-Gamut OKLCH Accent Color Palettes

Explore in Color Tokens Studio →

Generate high-chroma accent-color palettes that stay vivid in both light and dark mode without clipping sRGB gamuts.

Chaam
Chaam's Pro Tip

A trick I use in almost every project: don't fight specificity battles with !important. Leverage modern CSS cascade layers (@layer) and CSS variables as design tokens—it makes dark/light theme switching and responsive tuning effortless.

Why I Built the Form Controls Studio

I got tired of guessing values and testing browser quirks in DevTools, so I built this tool to tweak and preview values in real time with 1-click code export.

Open in Form Controls Studio ↗

Frequently Asked Questions

Practical answers to common implementation questions, browser quirks, and performance tips.

How do you style an HTML checkbox without breaking keyboard accessibility?

Keep the native in the DOM but hide it visually using opacity: 0 or absolute positioning. Ensure the

What does appearance: none do on mobile Safari iOS form inputs?

'appearance: none' removes Apple's default inner gradients, inset shadows, and rounded pill borders, allowing custom border-radius and background colors to render accurately on iPhone and iPad screens.

How do you make a pure CSS toggle switch keyboard focusable?

Since the switch is built on top of a native checkbox input, users can focus it via the Tab key and toggle it with the Spacebar. Styling 'input:focus-visible + .slider' with an outline ensures keyboard users see a clear focus halo.

Why do WebKit and Firefox require separate pseudo-elements for range slider styling?

Browsers treat unfamiliar pseudo-selectors as invalid syntax. If you group '::-webkit-slider-thumb, ::-moz-range-thumb' into a single selector rule, browsers that don't support one will drop the entire block. They must be declared in separate rules.

What is CSS accent-color and which form controls does it support?

'accent-color' is a single CSS property that instantly tints native checkboxes, radio buttons, range sliders, and progress bars while preserving the browser's native accessible OS micro-interactions.

← Back to all blog guides Launch Generator Studio →