Skip to main content

Toggle

The TkToggle component is another basic element for user input. You can use this for turning settings, features or true/false inputs on and off.

import { TkToggle } from '@takeoff-ui/react'

Basic

This demo visualizes the checked, unchecked states of a toggle component.

View Code
<TkToggle />

States

This example illustrates the disabled state of the toggle.

View Code
<TkToggle label="Disabled" disabled value={true} />
<TkToggle label="Invalid" invalid value={true} />

API

Props

NameTypeDefaultDescription
stringnullThe aria-labelledby attribute of the toggle.
booleanfalseWhether the toggle is disabled.
string'check'Specifies a material icon name to be displayed.
booleanfalseWhether the toggle is in an invalid state.
stringnullThe label for the toggle.
stringnullThe name attribute of the toggle.
booleantrueWhether to show the icon in the toggle.
"base", "large", "small", "xlarge", "xsmall"'base'Sets size for the component.
booleanfalseThe current state of the toggle.
"info", "success"'info'The type of the toggle.

Events

NameDescription
tk-changeEvent emitted when the toggle value changes.

Methods

NameDescription
getInputElementReturns the native <input> element used under the hood.