Bonusway design system

Forms

Toggle

An immediate on/off — an email preference, a visibility setting. Use it where the change applies as soon as it is flipped, with no save button.

import Toggle from '@/components/ui/Toggle';

Source: src/components/ui/Toggle.tsx

Examples

On and off

interactive

Email updates on

Props

<Toggle> props

PropTypeDefaultDescription
color'blue' | 'green' | 'red' | 'gold''blue'—

Also accepts everything in Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> — so native attributes (id, onClick, aria-*, data-*) pass straight through.

Accessibility

  • A real checkbox underneath, so Space toggles it. aria-label is required because the visual is a switch with no text.

Usage

Do

  • Pass aria-label (it is required) or label it with a Field-style label beside it.
  • Apply the change immediately, and confirm with a Toast if it is not visible on screen.

Don’t

  • Don’t put a Toggle in a form with a save button — a switch that has not taken effect yet is a lie about its state.

Šī lapa lieto sīkfailus

Mēs izmantojam sīkfailus, lai uzlabotu tavu pieredzi mūsu vietnē un pielāgotu saturu, ko mēs tev piedāvājam. Būtiski sīkfaili ir nepieciešami, lai mūsu pakalpojums darbotos pareizi. Ja esi priecīgs, ka mēs apkopojam informāciju, izmantojot mārketinga sīkdatnes, tad izvelies “Pieņemt visu”. Vienmēr vari mainīt minētos iestatījumus, apmeklējot sīkfailu iestatījumus.

Sīkfailu iestatījumi