DOCS
v0.4

Components / Switch

Switch

Toggle switch with spring-animated thumb, press stretch feedback, and error/success states.

formsv0.1.0

Playground

Examples

States
<cg-stack gap="sm"><cg-switch label="Notifications"></cg-switch><cg-switch label="Dark mode" checked></cg-switch><cg-switch label="Disabled" disabled></cg-switch></cg-stack>
Validation
<cg-stack gap="sm"><cg-switch label="Error" error checked></cg-switch><cg-switch label="Success" success checked></cg-switch><cg-switch label="Loading" loading></cg-switch></cg-stack>

Import

import { CgSwitch } from '@cognivo/components';
// Or tree-shake: import '@cognivo/components/cg-switch';

Per-component imports ship only that component (~8 kB gzip).

API Reference

PropTypeDefaultDescription
labelstring""Label text
checkedbooleanfalseOn/off state
disabledbooleanfalseDisabled state
errorbooleanfalseError state
successbooleanfalseSuccess state
loadingbooleanfalseLoading state

Events

EventDetailDescription
cg-change{checked: boolean}When toggled on/off