Skip to main content

Radio

The TkRadio component is another basic element for user input. You can use this to supply a way for the user to pick an option from multiple choices.

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

Basic​

View Code
<TkRadioGroup>
<TkRadio label="label 1" value="1" />
<TkRadio label="label 2" value="2" />
</TkRadioGroup>

State​

This demo showcases the disabled and invalid states of the radio component.

View Code
<TkRadioGroup invalid={true} label="Error">
<TkRadio label="label 1" value="1" />
<TkRadio label="label 2" value="2" />
</TkRadioGroup>
<TkRadioGroup invalid={true} label="Disabled">
<TkRadio label="label 1" value="1" disabled />
<TkRadio label="label 2" value="2" disabled />
</TkRadioGroup>

Type​

This demo showcases the type prop with default and card options.

View Code
<TkRadioGroup label="Default Type">
<TkRadio label="label 1" value="1" />
<TkRadio label="label 2" value="2" />
</TkRadioGroup>
<TkRadioGroup label="Card Type" type="card">
<TkRadio label="label 1" value="1" />
<TkRadio label="label 2" value="2" />
</TkRadioGroup>

Description​

This demo showcases the description prop.

View Code
<TkRadioGroup>
<TkRadio label="label 1" value="1" />
<TkRadio label="label 2" value="2" description="Example description" />
</TkRadioGroup>

Content Slot​

This demo illustrates the custom content slots.

Label
Label
View Code
<TkRadioGroup type="card" value="0" spread>
<TkRadio value="0">
<div slot="content" className="flex items-center gap-2">
<div>Label</div>
<TkBadge icon="info" variant="info" label="İnformation" />
</div>
</TkRadio>
<TkRadio value="1">
<div slot="content" className="flex items-center gap-2">
<div>Label</div>
<TkBadge icon="info" variant="info" label="İnformation" />
</div>
</TkRadio>
</TkRadioGroup>

Radio API​

Props​

NameTypeDefaultDescription
booleanfalseMarks the radio button as checked or unchecked.
stringnullThe description sub text displayed.
booleanfalseDisables the radio button if true.
booleanfalseIndicates whether the input is in an invalid state
stringnullDefines the label for the element.
stringnullThe name of the radio group, used to group radio buttons together.
"left", "right"nullDetermines the position of the radio and label.
anynullThe value of the radio button.

Events​

NameDescription
tk-changeEmitted when the radio button's checked state changes.

Slots​

NameDescription
contentCustom content template.

Radio Group API​

Props​

NameTypeDefaultDescription
"horizontal", "vertical"'horizontal'The direction of the radio buttons.
stringnullThis is the error message that will be displayed.
booleanfalseIndicates whether the input is in an invalid state
stringnullDefines the label for the element.
"left", "right"'left'Determines the position of the radio group and label.
booleanfalseDisplays a red asterisk (*) next to the label for visual emphasis.
booleanfalseDetermines whether the radios will spread evenly across the horizontal space.
"card", "default"'default'Determines the appearance types of radios.
anynullThe value of the input.

Events​

NameDescription
tk-changeEmitted when the value has changed.