Skip to content

ToggleCard

Card-style toggle switch with label and description.

Also known as: switch card, toggle setting card, option toggle card

View in Storybook

When to use

  • Rich toggle settings with label and description (notification preferences, feature flags). For simple toggles, use Toggle.
  • For card-style checkboxes, use CheckboxCard.

Import

tsx
import { ToggleCard } from '@vacano/ui'

Usage

tsx
const [enabled, setEnabled] = useState(false)

<ToggleCard
  checked={enabled}
  onChange={(e) => setEnabled(e.target.checked)}
  label="Email Notifications"
  description="Receive updates about your account"
/>

With Description

tsx
<ToggleCard
  checked={true}
  onChange={() => {}}
  label="Premium Plan"
  description="Access to all features and priority support"
/>

Full Width

tsx
<ToggleCard
  fullWidth
  checked={false}
  onChange={() => {}}
  label="Full Width Card"
  description="This card takes full width"
/>

Variants

tsx
<ToggleCard variant="normal" checked={true} onChange={() => {}} label="Normal" />
<ToggleCard variant="error" checked={true} onChange={() => {}} label="Error" />

Disabled

tsx
<ToggleCard disabled checked={true} onChange={() => {}} label="Disabled" />

Props

PropTypeDefaultDescription
checkedbooleanrequiredToggle state
onChangeChangeEventHandler<HTMLInputElement>requiredChange handler
labelstringrequiredLabel text
descriptionstring-Description text
fullWidthbooleanfalseFull width card
variant'normal' | 'error''normal'Visual variant
disabledbooleanfalseDisable card
classNamestring-CSS class for root element
classnamesToggleCardClassNames-Custom class names for inner elements
refRef<HTMLInputElement>-Ref to the underlying input element
data-test-idstring-Test identifier for automated testing

Also accepts all standard InputHTMLAttributes<HTMLInputElement> except type, checked, onChange, and className.

ClassNames

KeyDescription
toggleToggle element
contentContent container
labelLabel text
descriptionDescription text

Released under the MIT License.