The ToggleSwitch component is a reusable switch that supports both controlled and uncontrolled usage. It can display labels on both sides, emit updates on click, and be in a disabled state.
To begin, follow these steps:
-
Install dependencies:
npm install # or, if you prefer yarn: yarn
-
Start the development server:
npm run dev # or, if you prefer yarn: yarn dev
-
Navigate to http://localhost:5173/ to see a demo of the component.
- TypeScript
- SCSS and BEM styling
- Script setup
- Single File Component (SFC)
The component provides transitions between the unchecked, checked, and disabled states. It uses CSS transitions for this purpose.