UI

Switch

Alternate between selecting and deselecting.

Import Switch

Tremor exports one component to create a Switch

import { Switch } from '@tremor/react';

Usage example with controlled state

The example below shows a composition of a switch and a label.

Unlock the full potential

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt.

API Reference: Switch

client component
checked
boolean
Sets the default value item in uncontrolled mode.
defaultChecked
boolean

Default: false

The controlled state of Select. Must be used in conjunction with onChange.
onChange
(value: boolean) => void;
Callback function for when the value of the component changes.
color
Color

Default: blue

Set the color of the switch.
error
boolean

Default: false

If true, the text input is labeled as invalid.
errorMessage
string
Text to be displayed if the error prop is set to `true`.
disabled
boolean

Default: false

If true, the switch is not interactive.
required
boolean

Default: false

If true, indicates that the switch selection is necessary before submitting a form.
id
string
Defines a unique identifier (ID) which is used to reference the element.
tooltip
string
Set a tooltip on hover.

Theming

Switch

Roundness
borderRadiustremor-full
Background color
colorstremor-border
Shadow
boxShadowtremor-shadow-input