Import
import { Toggle } from '@strongtie/design-system/toggle' ;
Usage
< Toggle aria-label = "Toggle bold" >
< MdFormatBold />
</ Toggle >
Props Change the default rendered element for the one passed as a child, merging their props and behavior.
pressed
boolean
default: "undefined"
The controlled pressed state of the toggle.
defaultPressed
boolean
default: "undefined"
The default pressed state when the component is uncontrolled.
onPressedChange
(pressed: boolean) => void
default: "undefined"
Callback fired when the pressed state changes.
disabled
boolean
default: "undefined"
Whether the toggle is disabled.
variant
"default" | "outline"
default: "\"default\""
The visual variant of the toggle button.
size
"sm" | "default" | "lg"
default: "\"default\""
The size of the toggle button.
Styling Classes The component applies the following CSS classes:
toggle - Base toggle class
Usage Examples Basic
Icon
Outline Variant
Icon With Text
Different Sizes
Controlled
Disabled
As Child
Default Pressed
For more examples, visit the Storybook . The Blazor implementation provides a StudsToggle component that can be used individually or grouped together to create toggle group functionality. < StudsToggle @bind-Value = "isBold" Text = "Bold" Icon = "format_bold" />
<StudsToggle> ParametersThe current toggle state (true for active, false for inactive).
ValueChanged
EventCallback<bool>
default: "null"
Callback fired when the toggle state changes.
The name attribute for the underlying input element.
Whether the toggle button is disabled.
The text content displayed on the toggle button.
The icon displayed when the toggle is inactive.
The icon displayed when the toggle is active. Falls back to Icon if not specified.
ButtonStyle
ButtonStyle
default: "ButtonStyle.Primary"
The button style when the toggle is inactive.
ToggleButtonStyle
ButtonStyle
default: "ButtonStyle.Primary"
The button style when the toggle is active.
Size
ButtonSize
default: "ButtonSize.Medium"
The size of the toggle button.
Whether the toggle shows a loading/busy state.
Text displayed when the toggle is in busy state.
Change
EventCallback<bool>
default: "null"
Additional callback fired when the toggle state changes.
Click
EventCallback<MouseEventArgs>
default: "null"
Callback fired when the toggle is clicked.
ValueExpression
Expression<Func<bool>>
default: "null"
Expression for model binding in forms.
InputAttributes
IReadOnlyDictionary<string, object>
default: "null"
Additional attributes for the underlying input element.
The tab index for keyboard navigation.
Placeholder text for the toggle (used in form scenarios).
Attributes
Dictionary<string, object>
Specifies additional custom attributes that will be rendered by the component.
MouseEnter
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse enters an item.
MouseLeave
EventCallback<ElementReference>
Gets or sets the callback that is invoked when the mouse leaves an item.
A callback that will be invoked when the user right-clicks the component. Commonly used to display a context menu.
Culture
CultureInfo
default: "CultureInfo.CurrentCulture"
Gets or sets the culture used to display localizable data (numbers, dates). Set by default to “CultureInfo.CurrentCulture”.
Gets or sets the inline CSS style.
Gets or sets a value indicating whether this “T:Studs.StudsComponent” is visible. Invisible components are not rendered.
Styling Classes The component applies the following CSS classes:
toggle-button - Base toggle button class
-active - Applied when the toggle is active (Value = true)
-disabled - Applied when the toggle is disabled
-icon-only - Applied when only an icon is displayed (no text)
Usage Examples Basic Toggle
Icon Only
Icon With Text
Multiple Toggles
Disabled
Busy State
< StudsToggle @bind-Value = "isToggled"
Text = "Toggle"
ButtonStyle = "ButtonStyle.Ghost"
ToggleButtonStyle = "ButtonStyle.Secondary" />
For more examples, visit the Storybook .