Import
import { Switch } from '@strongtie/design-system/switch' ;
Props The controlled checked state of the switch.
The default checked state when first rendered.
onCheckedChange
(checked: boolean) => void
Event handler called when the checked state changes.
When true, prevents the user from interacting with the switch.
The name of the switch. Submitted with its form data.
The value given as data when submitted with a name.
When true, indicates that the user must check the switch before submitting the form.
Usage Examples Basic
Controlled
With Label
Disabled State
Form Integration
< Switch defaultChecked = {false} />
Styling Classes The following CSS classes are applied by the Switch component:
switch – Root switch container with state styling and interaction handling
switch-thumb – Movable thumb element that slides between on/off positions
For more examples, visit the Storybook . < StudsSwitch @bind-Value = "isEnabled" Change = " @( value = > HandleChange ( value ) ) " />
@code {
private bool isEnabled ;
private void HandleChange ( bool value )
{
Console . WriteLine ( $"Switch value changed to: { value }" );
}
}
Parameters Gets or sets the value of the switch. True represents on/checked, false represents off/unchecked.
Gets or sets the callback that is invoked when the Value is changed.
Gets or sets the callback that is invoked when the switch is toggled.
InputAttributes
IReadOnlyDictionary<string, object>
Specifies additional custom attributes that will be rendered by the input element.
Gets or sets the name attribute of the switch.
If true, the switch will be disabled and cannot be toggled.
Gets or sets the tab index for the switch.
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.
Usage Examples Basic
With Change Handler
With Label and Styling
Disabled State
Form Integration
< StudsSwitch @bind-Value = "isEnabled" />
@code {
bool isEnabled = false ;
}
Styling Classes The following CSS classes are applied by the Switch component:
switch – Root switch container with state management and interaction
switch.-checked – Applied when the switch is in the checked/on state
switch-graphic – Visual switch representation with thumb and track
switch-graphic.-disabled – Applied when the switch is disabled
For more examples, visit the Storybook .