<tk-toggle-button>
<div slot="legend" class="mb-2x">Movies</div>
</tk-toggle-button>
tk-toggle-button
renders a list of radio buttons based on a set of options. The options is an array of objects with label
and value
keys. It’s possible to use an HTML formatted label, using the htmlLabel
property instead of label
, which accepts HTML formatted code correctly processing strong
and em
and removing all the other tags.
Requires options
Prop to be bound, so that it’s set as an object instead of a string. In Angular, this is: [options]='[{ your object }]'
.
This requires JS to set the options
Prop, otherwise it’ll treat the value as a string. Read More →
<tk-toggle-button inline>
<div slot="legend" class="mb-2x">Movies</div>
</tk-toggle-button>
By default, the options are stacked. Set the inline
prop to make the options inline.
<tk-toggle-button fill-container>
<div slot="legend" class="mb-2x">Movies</div>
</tk-toggle-button>
By default, options are as wide as their content. To have them grow to the width of their container, set fill-container
.
<tk-toggle-button inline fill-container>
<div slot="legend" class="mb-2x">Movies</div>
</tk-toggle-button>
By default, options are as wide as their content. To divide the available horizontal space inside a container equally over the options, set both inline
and fill-container
.
<tk-toggle-button selected="willow">
<div slot="legend" class="mb-2x">Movies</div>
</tk-toggle-button>
Pass the selected
prop with the value of the option to set it to selected (:checked
) by default.
<tk-toggle-button size="large">
<div slot="legend" class="mb-2x">Movies</div>
</tk-toggle-button>
To render the toggle button in a large size, pass the size
property.
<tk-toggle-button size="large">
<div slot="error" class="l-inline-flex t-base">
<tk-icon aria-label="error" class="mr-2x mv-auto" name="alert" role="img" size="medium"></tk-icon>Example error message
</div>
<div slot="legend" class="mb-2x">Movies</div>
</tk-toggle-button>
Property | Attribute | Description | Type | Default |
---|---|---|---|---|
inline |
inline |
Controls the orientation of the options. If set to true, the options will be displayed horizontally. Otherwise, they will be stacked. | boolean |
false |
options |
– | An array of choices to render. This must be an array of objects of the ToggleButtonOption type. An optional “disabled” key can be set within the object to render an option as disabled. An optional “ariaLabel” key can be set within the object to specify a “aria-label” value. | ToggleButtonOption[] |
undefined |
required |
required |
Sets the HTML attribute of required. | boolean |
false |
selected |
selected |
A value that, if matches value in the options, will preselect that option. | string |
null |
size |
size |
Controls the size of the button | "large" | "medium" |
'medium' |
Event | Description | Type |
---|---|---|
checked |
The value of the currently selected option. | CustomEvent<string> |