A toggle control for on/off states that take effect immediately. Supports labels, descriptions, loading states, and validation. Use it for settings or preferences that apply instantly. For changes requiring a form submission, use a checkbox instead. Under a finger it moves like the iOS switch on every touch screen: a press lifts the thumb, a drag across flips it, lifting the finger commits, and a tap toggles through the browser’s click. The thumb keeps its circle and size on every device, and under a coarse pointer the invisible hit area grows toward 44 × 44 px, stopping halfway to any neighbouring control so a tap goes to the nearer one. With reduced motion on, a change cross-fades on a touch screen and is immediate with a mouse. Astryx by Meta. Source: https://astryx.atmeta.com/components/Switch
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Astryx Switch to your project and fits it to your theme.
Code
How Astryx Switch is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
'use client';
/* Copyright (c) 2026 Meta Platforms, Inc. See MIT notice in astryx-switch.tsx. */
import '@/components/ui/astryx-switch-utils/astryx-preview.css';
import {useState} from 'react';
import {Switch} from '@/components/ui/astryx-switch';
function OfficialSample() {
const [enabled, setEnabled] = useState(false);
return (
<Switch
label="Enable notifications"
value={enabled}
onChange={setEnabled}
/>
);
}
export default function Demo() {
return (
<div className="astryx-demo" data-astryx-theme="neutral" data-theme="light">
<div className="astryx-demo-content" data-centered style={{maxWidth: 350}}>
<OfficialSample />
</div>
</div>
);
}







