Skip to content

Latest commit

 

History

History
41 lines (29 loc) · 1.26 KB

File metadata and controls

41 lines (29 loc) · 1.26 KB
title Switch
parent Controls and forms
grand_parent Components

Switch

{: .no_toc }

A boolean that takes effect as soon as it moves.

import { Switch } from '@textui/widgets';

<Switch label="Follow tail" value onChange={(value) => console.log(value)} />

Props

Prop Type Default
label string
value boolean false
onChange (value: boolean) => void
labels [off: string, on: string] ['off', 'on'] Words either side, so the state reads without colour.

Plus everything on BoxProps.

Role: switch.

The difference from Checkbox is a promise to the reader, not a shape: a switch means the change has already happened, a checkbox means it will happen when the form is submitted. Putting a switch in a form with a Submit button breaks that promise.

labels renames the two states from ['off', 'on'], for a control whose states have names of their own.

See also