Class BOBSwitch<TValue>
- Namespace
- BlazOrbit.Components.Forms
- Assembly
- BlazOrbit.dll
[GenerateComponentInfo]
public class BOBSwitch<TValue> : BOBComponentBase, IHasSize, IHasDensity, IHasDisabled
Type Parameters
TValue
- Inheritance
-
objectComponentBaseBOBSwitch<TValue>
- Implements
- Inherited Members
Constructors
BOBSwitch()
public BOBSwitch()
Properties
AriaDescribedBy
ID of the element that describes the switch (forwarded as aria-describedby).
[Parameter]
public string AriaDescribedBy { get; set; }
Property Value
- string
AriaLabel
Accessible name for the component.
[Parameter]
public string? AriaLabel { get; set; }
Property Value
- string
Density
Vertical density (gap) of the component.
[Parameter]
public BOBDensity Density { get; set; }
Property Value
Disabled
When true, the switch cannot be toggled and is rendered as inactive.
[Parameter]
public bool Disabled { get; set; }
Property Value
- bool
IconActive
Icon shown when switch is checked (Option2)
[Parameter]
public IconKey? IconActive { get; set; }
Property Value
IconInactive
Icon shown when switch is unchecked (Option1)
[Parameter]
public IconKey? IconInactive { get; set; }
Property Value
InputId
Optional custom input ID. If not provided, one will be generated.
[Parameter]
public string? InputId { get; set; }
Property Value
- string
IsChecked
Whether the switch is currently checked (Value == Option2)
protected bool IsChecked { get; }
Property Value
- bool
IsDisabled
Computed disabled state, combining Disabled with internal conditions such as loading.
public bool IsDisabled { get; }
Property Value
- bool
Label
Label text displayed next to the switch
[Parameter]
public string? Label { get; set; }
Property Value
- string
OptionActive
Value when switch is in "on" state (checked)
[Parameter]
[EditorRequired]
public TValue OptionActive { get; set; }
Property Value
- TValue
OptionInactive
Value when switch is in "off" state (unchecked)
[Parameter]
[EditorRequired]
public TValue OptionInactive { get; set; }
Property Value
- TValue
Size
Visual size of the switch.
[Parameter]
public BOBSize Size { get; set; }
Property Value
ThumbBackgroundColorActive
Thumb background color when checked
[Parameter]
public string? ThumbBackgroundColorActive { get; set; }
Property Value
- string
ThumbBackgroundColorInactive
Thumb background color when unchecked
[Parameter]
public string? ThumbBackgroundColorInactive { get; set; }
Property Value
- string
ThumbColorActive
Thumb color when checked
[Parameter]
public string? ThumbColorActive { get; set; }
Property Value
- string
ThumbColorInactive
Thumb color when unchecked
[Parameter]
public string? ThumbColorInactive { get; set; }
Property Value
- string
TrackColorActive
Track background color when checked
[Parameter]
public string? TrackColorActive { get; set; }
Property Value
- string
TrackColorInactive
Track background color when unchecked
[Parameter]
public string? TrackColorInactive { get; set; }
Property Value
- string
Value
Current value of the switch
[Parameter]
public TValue? Value { get; set; }
Property Value
- TValue
ValueChanged
Callback when value changes
[Parameter]
public EventCallback<TValue?> ValueChanged { get; set; }
Property Value
- EventCallback<TValue>
Methods
BuildComponentCssVariables(Dictionary<string, string>)
Override this method in derived components to add custom CSS variables. These will be merged with the standard behavior CSS variables. This method is called from BOBComponentAttributesBuilder during the style building process.
public override void BuildComponentCssVariables(Dictionary<string, string> cssVariables)
Parameters
cssVariablesDictionary<string, string>Dictionary to add CSS variables to
BuildComponentDataAttributes(Dictionary<string, object>)
Override this method to add component-specific data attributes. Called during attribute building process.
public override void BuildComponentDataAttributes(Dictionary<string, object> dataAttributes)
Parameters
dataAttributesDictionary<string, object>
BuildRenderTree(RenderTreeBuilder)
Renders the component to the supplied Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.
protected override void BuildRenderTree(RenderTreeBuilder __builder)
Parameters
__builderRenderTreeBuilder