Toggle
BitToggle is a physical switch turned into a control: flip it to choose between two mutually exclusive options - “On/Off”, “Show/Hide” - and the choice takes effect right away, with no Save button in between. That immediacy is what separates it from a checkbox, which states an intention that a later submit carries out; a switch inside a long form that ends in a Submit button is the one place not to use it. The knob slides between the two ends of the track, so the state is carried by position as much as by color, and the slide collapses to a jump wherever reduced motion is asked for. It is built on a real focusable button with the switch role, so Tab reaches it, Space and Enter flip it, and screen readers announce it as a switch together with its state. Beyond the two plain states it can name each of them with a state text, put an icon or arbitrary content inside its track, explain itself in a description line, show a spinner for as long as the change is still in flight, refuse a change before it lands, be flipped from code, and place its label on any side of the knob.
Usage
Basic
<BitToggle Label="Basic" />
<BitToggle Label="On by default" DefaultValue="true" />
<BitToggle Label="Disabled" IsEnabled="false" />
<BitToggle Label="Disabled and on" IsEnabled="false" Value="true" />Texts
<BitToggle Label="Text" Text="This is a toggle!" />
<BitToggle Label="OnText & OffText" OnText="Toggle is On" OffText="Toggle is Off" />
<BitToggle Label="OnText only (Text as the fallback)" OnText="Enabled" Text="Not enabled yet" />Track content
<BitToggle Label="Text content">
<OnContent>ON</OnContent>
<OffContent>OFF</OffContent>
</BitToggle>
<BitToggle Label="Icon content" DefaultValue="true">
<OnContent><BitIcon IconName="@BitIconName.Accept" /></OnContent>
<OffContent><BitIcon IconName="@BitIconName.Cancel" /></OffContent>
</BitToggle>
<BitToggle Label="Only one side">
<OffContent>Click me</OffContent>
</BitToggle>Icons
<BitToggle Label="Both states" OnIconName="@BitIconName.Accept" OffIconName="@BitIconName.Cancel" />
<BitToggle Label="On state only" OnIconName="@BitIconName.CheckMark" DefaultValue="true" />
<BitToggle Label="Icon and track content" OnIconName="@BitIconName.Sunny" OffIconName="@BitIconName.ClearNight">
<OnContent>Day</OnContent>
<OffContent>Night</OffContent>
</BitToggle>
<BitToggle Label="Disabled" OnIconName="@BitIconName.Accept" OffIconName="@BitIconName.Cancel" IsEnabled="false" />Label
<BitToggle Label="This is an inline label" Inline />
<BitToggle>
<LabelTemplate>
<div style="display:flex;align-items:center;gap:10px">
<BitLabel Style="color:green">This is custom Label</BitLabel>
<BitIcon IconName="@BitIconName.Filter" />
</div>
</LabelTemplate>
</BitToggle>Label position
<BitToggle Label="Top" LabelPosition="BitLabelPosition.Top" />
<BitToggle Label="Bottom" LabelPosition="BitLabelPosition.Bottom" />
<BitToggle Label="Start" LabelPosition="BitLabelPosition.Start" />
<BitToggle Label="End" LabelPosition="BitLabelPosition.End" />Reversed
<BitToggle Label="This is a reversed label" Reversed />
<BitToggle Label="This is a reversed inline label" Reversed Inline />FullWidth
<BitToggle Label="This is a full-width toggle" FullWidth Inline />
<BitToggle Label="This is a reversed full-width toggle" Reversed FullWidth Inline />
<BitToggle FullWidth Inline>
<LabelTemplate>
<BitActionButton FullWidth>go go go</BitActionButton>
</LabelTemplate>
</BitToggle>Loading
<BitToggle Label="Save to the server" Loading="isSaving" Value="savedValue" OnChange="HandleSaveToggle" /> <div>Saved state: <b>@savedValue</b></div> <BitToggle Label="Save to the server (AutoLoading)" AutoLoading @bind-Value="autoLoadingValue" OnChange="SaveTheToggle" /> <BitToggle Label="Loading" Loading /> <BitToggle Label="Loading and on" Loading Value="true" /> <BitToggle Label="Loading with icons" Loading OnIconName="@BitIconName.Accept" OffIconName="@BitIconName.Cancel" />@code { private bool isSaving; private bool savedValue; private bool autoLoadingValue; private async Task HandleSaveToggle(bool value) { isSaving = true; await Task.Delay(1000); savedValue = value; isSaving = false; } private async Task SaveTheToggle(bool value) { // AutoLoading keeps the toggle busy for exactly as long as this callback takes await Task.Delay(1000); } }
Read-only & Required
<BitToggle Label="Read-only toggle" ReadOnly @bind-Value="readOnlyValue" Text="Locked" /> <BitToggleButton @bind-IsChecked="readOnlyValue" Text="Change it from here" /> <BitToggle Label="I accept the terms" Required />@code { private bool readOnlyValue; }
Binding
<BitToggle Label="Always on" Value="true" /> <BitToggle Label="One-way" Value="oneWayValue" /> <BitToggleButton @bind-IsChecked="oneWayValue" OnText="On" OffText="Off" /> <BitToggle Label="Two-way" @bind-Value="twoWayValue" /> <BitToggleButton @bind-IsChecked="twoWayValue" OnText="On" OffText="Off" /> <BitButton OnClick="() => methodToggleRef.ToggleAsync()">Flip it</BitButton> <BitButton OnClick="() => methodToggleRef.ToggleAsync(true)">Turn it on</BitButton> <BitButton OnClick="() => methodToggleRef.ToggleAsync(false)">Turn it off</BitButton> <BitToggle @ref="methodToggleRef" Label="Driven from code" ReadOnly Text="Read-only, still scriptable" OnChange="LogMethodChange" /> <div>@(string.IsNullOrEmpty(methodChangeLog) ? "Nothing changed yet." : methodChangeLog)</div>@code { private bool oneWayValue; private bool twoWayValue; private string methodChangeLog = string.Empty; private BitToggle methodToggleRef = default!; private void LogMethodChange(bool value) { methodChangeLog = $"OnChange fired with {value}"; } }
Events
<style> .clickable-box { padding: 1rem; cursor: pointer; width: fit-content; border-radius: 0.25rem; border: 1px dashed gray; } </style> <BitToggle Label="Flip me" OnClick="LogOnClick" OnChanging="LogOnChanging" OnChange="LogOnChange" /> <div>@(string.IsNullOrEmpty(eventsLog) ? "No clicks yet." : eventsLog)</div> <BitToggle Label="Allow the change" @bind-Value="allowChange" /> <BitToggle Label="Guarded toggle" OnChanging="HandleOnChanging" /> <div>Cancelled attempts: @cancelledCounter</div> <div class="clickable-box" @onclick="() => containerClickCounter++"> <BitToggle Label="Bubbles up" /> <BitToggle Label="Stops here" StopPropagation /> </div> <div>Container clicks: @containerClickCounter</div> <BitToggle Label="Focus me" OnFocus="LogOnFocus" OnBlur="LogOnBlur" OnFocusIn="LogOnFocusIn" OnFocusOut="LogOnFocusOut" /> <div>@(string.IsNullOrEmpty(focusLog) ? "Not focused yet." : focusLog)</div>@code { private string eventsLog = string.Empty; private string focusLog = string.Empty; private int cancelledCounter; private int containerClickCounter; private bool allowChange; private void LogOnClick() { eventsLog = "OnClick"; } private void LogOnChanging(BitToggleChangeArgs args) { eventsLog += $" → OnChanging (to {args.Value})"; } private void LogOnChange(bool value) { eventsLog += $" → OnChange ({value})"; } private void HandleOnChanging(BitToggleChangeArgs args) { if (allowChange) return; args.Cancel = true; cancelledCounter++; } private void LogOnFocus() { focusLog = "OnFocus"; } private void LogOnFocusIn() { focusLog += " → OnFocusIn"; } private void LogOnFocusOut() { focusLog = "OnFocusOut"; } private void LogOnBlur() { focusLog += " → OnBlur"; } }
Validation
<style> .validation-message { color: red; } </style> <EditForm Model="validationModel" OnValidSubmit="HandleValidSubmit" OnInvalidSubmit="HandleInvalidSubmit"> <DataAnnotationsValidator /> <BitToggle Label="Terms and conditions" Text="I agree." @bind-Value="validationModel.TermsAgreement" /> <ValidationMessage For="@(() => validationModel.TermsAgreement)" /> <BitButton ButtonType="BitButtonType.Submit">Submit</BitButton> </EditForm>@code { private BitToggleValidationModel validationModel = new(); public class BitToggleValidationModel { [Range(typeof(bool), "true", "true", ErrorMessage = "You must agree to the terms and conditions.")] public bool TermsAgreement { get; set; } } private void HandleValidSubmit() { } private void HandleInvalidSubmit() { } }
Accessibility
<BitToggle Label="Focus me with Tab, flip me with Space" /> <BitToggle Label="Hover over my knob" Title="The native tooltip of the toggle" /> <BitButton OnClick="FocusTheToggle">Focus the toggle</BitButton> <BitToggle @ref="toggleRef" Label="Programmatic focus target" /> <BitToggle AriaLabel="Dark mode" /> <BitToggle Label="Auto renew" AriaDescription="The subscription will be renewed one day before it expires." /> <div id="offline-mode-heading"><b>Offline mode</b></div> <div id="offline-mode-hint">Keep a copy of the last synced data on this device.</div> <BitToggle AriaLabelledby="offline-mode-heading" AriaDescribedby="offline-mode-hint" Text="Enabled" /> <BitToggle Label="Show advanced settings" AriaControls="advanced-settings-panel" @bind-Value="advancedSettingsVisible" /> <div id="advanced-settings-panel"> @if (advancedSettingsVisible) { <BitMessage Color="BitColor.Info">The panel this toggle controls.</BitMessage> } </div> <BitToggle Text="Dark mode" /> <BitToggle Label="Notifications" OnText="Allowed" OffText="Blocked" />@code { private BitToggle toggleRef = default!; private bool advancedSettingsVisible; private async Task FocusTheToggle() { await toggleRef.FocusAsync(); } }
Description
<BitToggle Label="Auto renew"
Description="The subscription is renewed one day before it expires." />
<div style="max-width:32rem">
<BitToggle FullWidth Inline
Label="Offline mode"
Description="Keep a copy of the last synced data on this device." />
<BitToggle FullWidth Inline
Label="Usage statistics"
Description="Send anonymous usage data to help us prioritize what to build next." />
</div>
<BitToggle Label="Beta features">
<DescriptionTemplate>
Turning this on opts you into features that are still changing.
<BitLink Href="https://bitplatform.dev" Target="_blank">Learn more</BitLink>
</DescriptionTemplate>
</BitToggle>Color
<BitToggle Color="BitColor.Primary" Label="Primary" Value />
<BitToggle Color="BitColor.Secondary" Label="Secondary" Value />
<BitToggle Color="BitColor.Tertiary" Label="Tertiary" Value />
<BitToggle Color="BitColor.Info" Label="Info" Value />
<BitToggle Color="BitColor.Success" Label="Success" Value />
<BitToggle Color="BitColor.Warning" Label="Warning" Value />
<BitToggle Color="BitColor.SevereWarning" Label="SevereWarning" Value />
<BitToggle Color="BitColor.Error" Label="Error" Value />
<div style="background:var(--bit-clr-fg-sec);color:var(--bit-clr-bg-sec);padding:1rem">
<BitToggle Color="BitColor.PrimaryBackground" Label="PrimaryBackground" Value />
<BitToggle Color="BitColor.SecondaryBackground" Label="SecondaryBackground" Value />
<BitToggle Color="BitColor.TertiaryBackground" Label="TertiaryBackground" Value />
</div>
<BitToggle Color="BitColor.PrimaryForeground" Label="PrimaryForeground" Value />
<BitToggle Color="BitColor.SecondaryForeground" Label="SecondaryForeground" Value />
<BitToggle Color="BitColor.TertiaryForeground" Label="TertiaryForeground" Value />
<BitToggle Color="BitColor.PrimaryBorder" Label="PrimaryBorder" Value />
<BitToggle Color="BitColor.SecondaryBorder" Label="SecondaryBorder" Value />
<BitToggle Color="BitColor.TertiaryBorder" Label="TertiaryBorder" Value />
<BitToggle Color="BitColor.Success" Label="Success" />
<BitToggle Color="BitColor.Warning" Label="Warning" />
<BitToggle Color="BitColor.Error" Label="Error" />External Icons
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.0.1/css/all.min.css" />
<BitToggle Label="Check / Xmark (string)" OnIcon="@("fa-solid fa-check")" OffIcon="@("fa-solid fa-xmark")" />
<BitToggle Label="Sun / Moon (BitIconInfo.Fa)" Color="BitColor.Warning"
OnIcon="@BitIconInfo.Fa("solid sun")" OffIcon="@BitIconInfo.Fa("solid moon")" />
<BitToggle Label="Rocket (BitIconInfo.Css)" Color="BitColor.Error" OnIcon="@BitIconInfo.Css("fa-solid fa-rocket")" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css" />
<BitToggle Label="Check / X (string)" OnIcon="@("bi bi-check-lg")" OffIcon="@("bi bi-x-lg")" />
<BitToggle Label="Bell (BitIconInfo.Bi)" Color="BitColor.Success"
OnIcon="@BitIconInfo.Bi("bell-fill")" OffIcon="@BitIconInfo.Bi("bell-slash")" />Size
<BitToggle Size="BitSize.Small" Label="Off" />
<BitToggle Size="BitSize.Small" Label="On" Value />
<BitToggle Size="BitSize.Small" Label="With icons" Value OnIconName="@BitIconName.Accept" OffIconName="@BitIconName.Cancel" />
<BitToggle Size="BitSize.Medium" Label="Off" />
<BitToggle Size="BitSize.Medium" Label="On" Value />
<BitToggle Size="BitSize.Medium" Label="With icons" Value OnIconName="@BitIconName.Accept" OffIconName="@BitIconName.Cancel" />
<BitToggle Size="BitSize.Large" Label="Off" />
<BitToggle Size="BitSize.Large" Label="On" Value />
<BitToggle Size="BitSize.Large" Label="With icons" Value OnIconName="@BitIconName.Accept" OffIconName="@BitIconName.Cancel" />Style & Class
<style>
.custom-class {
padding: 0.5rem;
border-radius: 0.25rem;
background-color: #d3d3d347;
border: 1px solid dodgerblue;
}
.custom-thumb {
background: #fff;
}
.custom-button {
padding: 0;
width: 52px;
height: 22px;
border: none;
background: #ccc;
border-radius: 11px;
--bit-tgl-pad: -4px;
--bit-tgl-thb-size: 30px;
}
.custom-check .custom-thumb {
background: #ff6868;
}
.custom-check .custom-button {
background: #ffcece;
}
.custom-check .custom-button:hover .custom-thumb {
background: #ff6868;
}
.custom-on-content {
font-weight: 700;
letter-spacing: 0.1em;
}
.custom-off-content {
opacity: 0.75;
font-style: italic;
}
</style>
<BitToggle Label="Styled toggle" Style="background-color:#ff6a00b3;padding:0.5rem;border-radius:0.25rem" />
<BitToggle Label="Classed toggle" Class="custom-class" />
<BitToggle Label="Styles"
Styles="@(new() { Root = "--toggle-background: lightgray;", Checked = "--toggle-background: #2ecc71;",
Thumb = "background: whitesmoke;",
Button = "background: var(--toggle-background); border: none; border-radius: 60px; padding: 0; height: 30px; width: 50px; --bit-tgl-pad: 2px; --bit-tgl-thb-size: 26px;" } )" />
<BitToggle Label="Classes"
Classes="@(new() { Thumb = "custom-thumb",
Button = "custom-button",
Checked = "custom-check" } )" />
<BitToggle Label="Each side of the track content"
Classes="@(new() { OnContent = "custom-on-content",
OffContent = "custom-off-content" } )">
<OnContent>ON</OnContent>
<OffContent>OFF</OffContent>
</BitToggle>RTL
<BitToggle Label="این یک تاگل است" Dir="BitDir.Rtl" OnText="روشن" OffText="خاموش" />
<BitToggle Label="این یک تاگل خطی است" Dir="BitDir.Rtl" Inline />
<BitToggle Label="این یک تاگل خطی برعکس است" Dir="BitDir.Rtl" Reversed Inline />
<BitToggle Label="این یک تاگل با محتوا است" Dir="BitDir.Rtl" OnIconName="@BitIconName.Accept" OffIconName="@BitIconName.Cancel">
<OnContent>روشن</OnContent>
<OffContent>خاموش</OffContent>
</BitToggle>API
BitToggle parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaControls | string? | null | The id of the element the toggle controls, rendered as aria-controls on the switch. |
| AriaDescription | string? | null | Detailed description of the toggle for the benefit of screen readers, rendered as a visually hidden element that the switch points to via aria-describedby. |
| AriaDescribedby | string? | null | The id of an existing element that describes the toggle, added to the aria-describedby of the switch alongside its state text and its AriaDescription rather than replacing them. |
| AriaLabelledby | string? | null | The id of an existing element that labels the toggle, rendered as aria-labelledby on the switch. Takes precedence over the label of the toggle and over AriaLabel. |
| AutoFocus | bool | false | If true, the toggle automatically receives focus when the page renders (rendered as the autofocus attribute). |
| AutoLoading | bool | false | Turns the toggle busy on its own for as long as the awaited OnClick, OnChanging and OnChange callbacks behind a change are still running, without a loading flag having to be tracked outside the component. |
| Classes | BitToggleClassStyles? | null | Custom CSS classes for different parts of the toggle. |
| Color | BitColor? | null | The general color of the toggle, applied to the track of the checked state. |
| Description | string? | null | A visible explanation of what the toggle switches, rendered on a line of its own under it and announced after the name of the switch through aria-describedby. |
| DescriptionTemplate | RenderFragment? | null | Custom description of the toggle, replacing Description with arbitrary markup. |
| FullWidth | bool | false | Renders the toggle in full width of its container while putting space between the label and the knob. |
| Inline | bool | false | Renders the label and the knob in a single line together. |
| Label | string? | null | Label of the toggle. |
| LabelPosition | BitLabelPosition? | null | The position of the label in regards to the knob of the toggle. Takes precedence over Inline and Reversed when set. |
| LabelTemplate | RenderFragment? | null | Custom label of the toggle. |
| Loading | bool | false | Renders a spinner in place of the knob's icon and suspends the toggle until the pending work behind the change is done. |
| OffContent | RenderFragment? | null | Content rendered inside the track of the toggle while it is OFF, next to the knob. |
| OffIcon | BitIconInfo? | null | The icon rendered inside the knob while the toggle is OFF, using custom CSS classes for external icon libraries. Takes precedence over OffIconName when both are set. |
| OffIconName | string? | null | The name of the built-in icon rendered inside the knob while the toggle is OFF. |
| OffText | string? | null | Text to display when toggle is OFF. |
| OnBlur | EventCallback<FocusEventArgs> | Callback for when the toggle loses focus. | |
| OnChanging | EventCallback<BitToggleChangeArgs> | Callback invoked before the state of the toggle changes, letting the change be cancelled by setting Cancel on the provided arguments. | |
| OnClick | EventCallback<MouseEventArgs> | Callback for when the toggle is clicked, invoked before the state changes. | |
| OnContent | RenderFragment? | null | Content rendered inside the track of the toggle while it is ON, next to the knob. |
| OnFocus | EventCallback<FocusEventArgs> | Callback for when the toggle receives focus. | |
| OnFocusIn | EventCallback<FocusEventArgs> | Callback for when focus moves into the toggle. | |
| OnFocusOut | EventCallback<FocusEventArgs> | Callback for when focus moves out of the toggle. | |
| OnIcon | BitIconInfo? | null | The icon rendered inside the knob while the toggle is ON, using custom CSS classes for external icon libraries. Takes precedence over OnIconName when both are set. |
| OnIconName | string? | null | The name of the built-in icon rendered inside the knob while the toggle is ON. |
| OnText | string? | null | Text to display when toggle is ON. |
| Reversed | bool | false | Reverses the positions of the label and input of the toggle. |
| Role | string? | switch | Denotes role of the toggle, default is switch. |
| Size | BitSize? | null | The size of the toggle. |
| StopPropagation | bool | false | If true, stops the click event from bubbling up to the parent elements. |
| Styles | BitToggleClassStyles? | null | Custom CSS styles for different parts of the toggle. |
| Text | string? | null | The default text used when the On or Off texts are null. |
| Title | string? | null | The native tooltip of the knob of the toggle, shown on hover. |
BitToggle public members
| Name | Type | Default value | Description |
|---|---|---|---|
| InputElement | ElementReference | The ElementReference of the switch button of the BitToggle - the element that holds the tab stop, not the hidden checkbox that carries the value into a form. | |
| FocusAsync | (bool preventScroll = false) => ValueTask | Gives focus to the switch button of the BitToggle. Pass true to keep the browser from scrolling the toggle into view along the way. | |
| ToggleAsync | () => Task | Flips the state of the BitToggle from code, as a click would: OnChanging still gets to cancel the change and OnChange still reports it. Unlike a click it is not blocked by the read-only or loading states, which only close the toggle to the user; a disabled toggle changes through neither. | |
| ToggleAsync | (bool value) => Task | Moves the BitToggle to a specific state from code, doing nothing when it is already in it. Otherwise identical to the parameterless overload. |
BitInputBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| DefaultValue | TValue? | null | The default value of the input to be used in uncontrolled mode (i.e. when the Value is not bound), typically used alongside the OnChange callback. |
| DisplayName | string? | null | Gets or sets the display name for this field. |
| InputHtmlAttributes | IReadOnlyDictionary<string, object>? | null | Gets or sets a collection of additional attributes that will be applied to the created element. |
| Name | string? | null | Gets or sets the name of the element. Allows access by name from the associated form. |
| NoValidate | bool | false | Disables the validation of the input. |
| OnChange | EventCallback<TValue?> | Callback for when the input value changes. | |
| ReadOnly | bool | false | Makes the input read-only. |
| Required | bool | false | Makes the input required. |
| Value | TValue? | null | Gets or sets the value of the input. This should be used with two-way binding. |
BitInputBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| InputElement | ElementReference | The ElementReference of the input element. | |
| FocusAsync() | () => ValueTask | Gives focus to the input element. | |
| FocusAsync(bool preventScroll) | (bool preventScroll) => ValueTask | Gives focus to the input element. |
BitComponentBase parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| AriaLabel | string? | null | Gets or sets the accessible label for the component, used by assistive technologies. |
| Class | string? | null | Gets or sets the CSS class name(s) to apply to the rendered element. |
| Dir | BitDir? | null | Gets or sets the text directionality for the component's content. |
| ForceAnimation | bool | false | Gets or sets a value indicating whether the component's animations play at their full duration even when reduced motion is requested. |
| HtmlAttributes | Dictionary<string, object> | new Dictionary<string, object>() | Captures additional HTML attributes to be applied to the rendered element, in addition to the component's parameters. |
| Id | string? | null | Gets or sets the unique identifier for the component's root element. |
| IsEnabled | bool | true | Gets or sets a value indicating whether the component is enabled and can respond to user interaction. |
| Style | string? | null | Gets or sets the CSS style string to apply to the rendered element. |
| TabIndex | string? | null | Gets or sets the tab order index for the component when navigating with the keyboard. |
| Visibility | BitVisibility | BitVisibility.Visible | Gets or sets the visibility state (visible, hidden, or collapsed) of the component. |
BitComponentBase public members
| Name | Type | Default value | Description |
|---|---|---|---|
| UniqueId | Guid | Guid.NewGuid() | Gets the readonly unique identifier for the component's root element, assigned when the component instance is constructed. |
| RootElement | ElementReference | Gets the reference to the root HTML element associated with this component. |
BitToggleClassStyles properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Root | string? | null | Custom CSS classes/styles for the root element of the BitToggle. |
| Label | string? | null | Custom CSS classes/styles for the label of the BitToggle. |
| Description | string? | null | Custom CSS classes/styles for the description of the BitToggle. |
| Container | string? | null | Custom CSS classes/styles for the container of the BitToggle. |
| Button | string? | null | Custom CSS classes/styles for the button of the BitToggle. |
| Checked | string? | null | Custom CSS classes/styles for the checked state of the BitToggle. |
| Content | string? | null | Custom CSS classes/styles for the content rendered inside the track of the BitToggle. |
| OnContent | string? | null | Custom CSS classes/styles for the ON side of the content rendered inside the track of the BitToggle. |
| OffContent | string? | null | Custom CSS classes/styles for the OFF side of the content rendered inside the track of the BitToggle. |
| Thumb | string? | null | Custom CSS classes/styles for the thumb of the BitToggle. |
| Icon | string? | null | Custom CSS classes/styles for the icon rendered inside the thumb of the BitToggle. |
| Spinner | string? | null | Custom CSS classes/styles for the loading spinner of the BitToggle. |
| Text | string? | null | Custom CSS classes/styles for the text of the BitToggle. |
BitToggleChangeArgs properties
| Name | Type | Default value | Description |
|---|---|---|---|
| Value | bool | false | The state the toggle is about to move to (read-only). |
| Cancel | bool | false | Set to true to cancel the change and keep the current state of the toggle. |
BitColor enum
| Name | Value | Description |
|---|---|---|
| Primary | 0 | Primary general color. |
| Secondary | 1 | Secondary general color. |
| Tertiary | 2 | Tertiary general color. |
| Info | 3 | Info general color. |
| Success | 4 | Success general color. |
| Warning | 5 | Warning general color. |
| SevereWarning | 6 | SevereWarning general color. |
| Error | 7 | Error general color. |
| PrimaryBackground | 8 | Primary background color. |
| SecondaryBackground | 9 | Secondary background color. |
| TertiaryBackground | 10 | Tertiary background color. |
| PrimaryForeground | 11 | Primary foreground color. |
| SecondaryForeground | 12 | Secondary foreground color. |
| TertiaryForeground | 13 | Tertiary foreground color. |
| PrimaryBorder | 14 | Primary border color. |
| SecondaryBorder | 15 | Secondary border color. |
| TertiaryBorder | 16 | Tertiary border color. |
BitLabelPosition enum
| Name | Value | Description |
|---|---|---|
| Top | 0 | The label shows on the top of the toggle. |
| End | 1 | The label shows on the end of the toggle. |
| Bottom | 2 | The label shows on the bottom of the toggle. |
| Start | 3 | The label shows on the start of the toggle. |
BitSize enum
| Name | Value | Description |
|---|---|---|
| Small | 0 | The small size toggle. |
| Medium | 1 | The medium size toggle. |
| Large | 2 | The large size toggle. |
BitVisibility enum
| Name | Value | Description |
|---|---|---|
| Visible | 0 | The content of the component is visible. |
| Hidden | 1 | The content of the component is hidden, but the space it takes on the page remains (visibility:hidden). |
| Collapsed | 2 | The component is hidden (display:none). |
BitDir enum
| Name | Value | Description |
|---|---|---|
| Ltr | 0 | Ltr (left to right) is to be used for languages that are written from the left to the right (like English). |
| Rtl | 1 | Rtl (right to left) is to be used for languages that are written from the right to the left (like Arabic). |
| Auto | 2 | Auto lets the user agent decide. It uses a basic algorithm as it parses the characters inside the element until it finds a character with a strong directionality, then applies that directionality to the whole element. |
Feedback
You can give us your feedback through our GitHub repo by filing a new Issue or starting a new Discussion.
Or you can review / edit this page on GitHub.