Description
react-switch is a React toggle-switch component that you can drag with a mouse or a touch screen, as well as click. It is built to be customizable, so you can change the size, the colors and other appearance settings through its props. The component is written to be accessible to people who are visually impaired or who cannot use a mouse. The README explains that the switch should sit inside a label element, so screen readers read the label text and clicking the text also toggles the switch. If you prefer not to nest the switch, you can connect a label to it with the htmlFor attribute, or give it a name with the aria-labelledby or aria-label props. The README includes a demo page with examples of each approach. The project documents its API in a table of props with types and defaults, and it describes the package as small. The repository is on GitHub, where you can open issues and contribute, and the project lists its contributors. The component is aimed at React developers who need a switch control in a form or settings screen that works with assistive technology.…
Highlights
- Drag with a mouse or a touch screen
- Customizable size and colors
- Accessible labelling with label, htmlFor and ARIA
- Small package with a documented prop API
Ratings & Reviews
No ratings yet
Be the first to rate react-switch.
People also visit
react-switch FAQ
What is react-switch?
It is a draggable toggle-switch component for React that you can use in forms and settings screens.
Can it be dragged?
Yes. You can drag it with a mouse or a touch screen, and it can also be clicked.
How do I make it accessible?
Nest the switch inside a label element so the label is read out. If you do not nest it, use htmlFor on the label, or aria-labelledby or aria-label on the switch.
Can I change the look?
Yes. Size, color and other appearance settings can be customized through its props.
Where is the documentation?
The README has usage examples, an API table with the props, types and defaults, and a link to the demo page.
What are the best react-switch alternatives?
Popular alternatives to react-switch include react-toggle, react-swipeable-views and react-range. See all react-switch alternatives





















