Skip to content
Toolars
Explore

CSS Switch Generator

18 switch templates: six thumb shapes × three transitions; test the native control by click or keyboard.

Local processing

Processing details

Tool inputs are processed on your device.

Resources may be downloaded to run this tool. Account services are separate.

Privacy information
Report bug

Task path / input to outcome

How to design a pure-CSS switch

  1. 01

    Size the track

    Set Track width between 44 and 128 px and Track height between 24 and 64 px. The width must exceed the height by at least 8 px so the thumb has room to travel. The 64 by 34 px default mirrors the proportions of most mobile switches. 18 Templates · Checked · Color

  2. 02

    Fit the thumb

    Choose a Thumb size from 16 to 56 px. It must sit inside the track — no larger than the track height minus 4 px — or the status flips to CHECK VALUES with the exact rule that failed.

  3. 03

    Color both states

    For the basic preset (gallery templates use their own shapes, colors, markup and timing): Pick Inactive track for the off position and Active track for the on position. The thumb itself stays white with a small soft shadow, so both track colors only need to contrast with white.

  4. 04

    Preview the transition

    For the basic preset (gallery templates use their own shapes, colors, markup and timing): Toggle Show active state to watch the thumb slide and the track recolor at the real 180 ms ease timing. The padding around the thumb is computed as half the leftover track height, so the fit stays even at any size you choose.

  5. 05

    Copy or download the CSS

    Press Copy CSS or Download .css to save toolars-switch.css. The white thumb slides the computed travel distance between states, and the export includes focus and reduced-motion handling from the start. The output panel shows the live byte count, so you can see how compact the component stays.

  6. 06

    Assemble the markup

    Place a checkbox input followed by a .switch-track element inside a .switch wrapper, in exactly that order — the sibling selector depends on it. The input shrinks to an invisible 1 px box but stays focusable, and focus draws a 3 px outline in your Active track color. HTML includes the current CSS and a working example. Native controls support keyboard input.

Tool facts

Processing
In your browser
Input leaves this device
Never
Retention
Nothing is stored
Price
Free

Your input stays in the browser.

CSS Switch Generator uses its verified local execution path and does not create a hidden input or output history.

Local execution

Runs inside the current browser tab.

No hidden processing

Active tool data never becomes a Toolars document record.

No account required

Use the core workflow without creating a profile. Favorites sync to your account after you sign in.

Immediate reset

Clear the tab and the active working data is gone.

What CSS Switch Generator actually does

Dark-mode toggles, notification switches, feature flags in a settings panel — the same component appears everywhere, and nudging its geometry in a browser inspector is slow. Here the track, thumb, and travel distance are settled visually in one pass, the export keeps a real input for keyboard and assistive-technology support, and the experiments never leave the tab. The result drops into a design system without a single line of JavaScript. Both states can be reviewed side by side before anything is copied.

Common questions

What markup does the export expect?
A .switch wrapper containing a checkbox input followed by a .switch-track element. The input is visually hidden but remains focusable and operable, so the finished switch behaves like the native control it wraps. 18 switch templates: six thumb shapes × three transitions; test the native control by click or keyboard. HTML includes the current CSS and a working example. Native controls support keyboard input.
Which geometry rules are enforced?
Two: the track width must be at least 8 px larger than its height, and the thumb must fit inside the track — at most the height minus 4 px. Breaking either shows CHECK VALUES, and copy and download stay disabled until the values pass.
How far does the thumb travel?
The stylesheet computes it from your numbers: track width minus thumb size minus the padding at both ends, so the thumb lands flush against the track edge in both the off and on positions.
Does the export handle reduced motion?
For the basic preset (gallery templates use their own shapes, colors, markup and timing): Yes. A prefers-reduced-motion block removes both 180 ms transitions — the track recolor and the thumb slide — so the state change still happens but lands instantly, with no movement at all.
What visual details are baked in?
For the basic preset (gallery templates use their own shapes, colors, markup and timing): The track is always a full pill, because its corner radius is half the track height, and the white thumb carries a small fixed drop shadow for lift. Everything else — colors, geometry, travel distance — comes straight from your control values.
Are my designs uploaded?
No. The workspace runs entirely in the current browser tab with no account, and no value is stored, logged, or sent anywhere. Once the page is loaded, the generator also keeps working without a network connection. Press Reset to restore the defaults.

Related tasks, not a dead end.

Move into another focused workspace without returning to the full index.

CSS Loader Generator

264 loader templates: 24 geometries × 11 motion profiles; filter by category and inspect the animation.

Create

CSS Checkbox Generator

24 checkbox templates: eight marks × three transitions; click or press Space in the native preview.

Create

CSS Clip Path Generator

24 clip shapes, primitive parameters and editable polygon points; export CSS or a declaration.

Create