{"repo":"react-component/switch","free":true,"listed":false,"github":"https://github.com/react-component/switch","clone":"git clone https://github.com/react-component/switch.git","description":"🔘 Accessible React switch for boolean state with controlled and uncontrolled modes.","language":"JavaScript","stars":196,"topics":["ant-design","antd","javascript","react","react-component"],"license":"MIT","category":"ui-components","readme_excerpt":"@rc-component/switch Part of the Ant Design ecosystem. 🔘 Accessible React switch for boolean state with controlled and uncontrolled modes. English 简体中文 Highlights - Renders a native button with role=\"switch\" and aria-checked state. - 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. Install Usage Online preview: https://switch.react-component.vercel.app/ Examples Run the local dumi site: Then open http://localhost:8000 . API Name Type Default Description ------------------- ----------------------------------- ------------- ------------------------------------------ autoFocus boolean - Focus the switch on mount. checked boolean - Controlled checked state. checkedChildren React.ReactNode - Content shown when checked. className string - Additional class name. classNames { content?: string } - Semantic class names for internal content. defaultChecked boolean false Initial checked state. disabled boolean false Disable interaction. loadingIcon React.ReactNode - Extra loading icon node. onChange (checked, event) = void - Triggered after checked state changes. onClick (checked, event) = void - Triggered after click. onKeyDown React.KeyboardEventHandler - Key down handler. prefixCls string 'rc-switch' Prefix class name. style React.CSSProperties - Root style. styles { content?: React.CSSProperties } - Semantic styles for internal content. tabIn","default_branch":null,"files":null,"tree":[],"storefront":"/r/react-component","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/react-component/switch/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}