Part of the Ant Design ecosystem.
🔘 Accessible React switch for boolean state with controlled and uncontrolled modes.
English | 简体中文
- Renders a native button with
role="switch"andaria-checkedstate. - Supports controlled and uncontrolled checked state.
- Handles click and keyboard toggles with left and right arrow keys.
- Provides content class/style slots for checked and unchecked labels.
npm install @rc-component/switchimport Switch from '@rc-component/switch';
import '@rc-component/switch/assets/index.css';
export default () => <Switch checkedChildren="On" unCheckedChildren="Off" />;Online preview: https://switch.react-component.vercel.app/
Run the local dumi site:
npm install
npm startThen open http://localhost:8000.
npm install
npm start
npm test
npm run tsc
npm run compile
npm run buildThe dumi site runs at http://localhost:8000 by default.
npm run prepublishOnlyThe release flow is handled by @rc-component/np through the rc-np command after the package build.
@rc-component/switch is released under the MIT license.
