Controls

Spring Switch

A switch whose knob stretches on the way and lands on the spring.

Preview

Installation

Terminal
npx @usefluid/cli add spring-switch

Usage

SpringSwitch.tsx
import { SpringSwitch } from "./SpringSwitch";

<SpringSwitch label="Email notifications" checked={emails} onChange={setEmails} />

API reference

PropTypeDefaultDescription
checkedboolean—
onChange(checked) => void—
labelstring—Visible and announced.
classNamestring—For layout, like full width in a settings list.

Keyboard and screen readers

role="switch" with aria-checked. Works in high contrast mode.

Notes

The thumb uses --fluid-on-accent, so it stays visible in light and dark themes.

Every colour comes from the --fluid-* variables, and the piece is yours to change.

How it is made

The knob's position is a spring. The faster it moves, the more it stretches sideways and thins vertically, and when it stops it is a circle again. It is a button with the switch role, so screen readers announce on and off.

For your agent

For your agent

Add Spring Switch to my project with the Fluid library. Use SpringSwitch for preferences that apply right away. Read my project first. Use my logo, my colours and my font through the --fluid-* variables. Keep 44px touch targets, visible focus and reduced motion. If I have no SVG logo, ask before making one up.