Toggle 03
A label-driven binary toggle with a sliding active surface, clear state hierarchy, and responsive capsule-based interaction.
Requirements
HTML, CSS, JavaScript
Dependencies
None
Usage
Copy index.html, styles.css and script.js into your project.
Typography: Inter, with a system sans-serif fallback.
About Toggle 03
Toggle 03 is a toggle component in the Toggle Components collection, available in HTML + CSS + JavaScript and React + TypeScript + Tailwind CSS. Last updated September 10, 2026.
- toggle
- label toggle
What the code includes
HTML + CSS + JavaScript
3 files: index.html, styles.css, script.js
- Behavior is handled in script.js.
- ARIA in the markup: roles radiogroup, radio; aria-label, aria-checked.
- HTML elements used: button.
- Keyboard keys handled: ArrowLeft, ArrowRight.
- Includes a prefers-reduced-motion rule for its animation.
React + TypeScript + Tailwind CSS
3 files: Toggle03.jsx, Toggle03.types.ts, Toggle03.tailwind.css
- Configurable through 7 props: label, options, value, defaultValue, onValueChange, disabled, className.
- Uses React hooks: useId, useState.
- ARIA in the markup: roles radio, radiogroup; aria-label, aria-checked.
- HTML elements used: button.
- Keyboard keys handled: ArrowLeft, ArrowRight.