v7.3.0

SlideToggle
Widget

A toggle switch widget — a visually distinct variation of Checkbox that renders a sliding track-and-thumb instead of a traditional check mark. It wraps <input type="checkbox"> and shares all Checkbox functionality including color, text label, and two-way data binding. Optionally display a label to the right of the toggle via text, in addition to the standard field label. This field can be used as a cell editor in a Grid.

const toggle = new SlideToggle({
    label   : 'Notifications',
    text    : 'Enable',
    checked : true,
    appendTo : document.body
});

Useful configs and properties

Config Description
checked Initial checked state
text Label text displayed to the right of the toggle
color Color of the toggle track
label Field label displayed beside the toggle
value Gets or sets the current toggle value

See also

No results

Properties

Properties are getters/setters or publicly accessible variables on this class

CSS variables

CSS variables that can be set to adjust appearance
Name Description
--b-slide-toggle-background Background
--b-slide-toggle-border-color Border color
--b-slide-toggle-border-radius SlideToggle border-radius
--b-slide-toggle-border-width SlideToggle border-width
--b-slide-toggle-focus-outline-color Focus outline color
--b-slide-toggle-focus-outline-offset Focus outline offset
--b-slide-toggle-focus-outline-width Focus outline width
--b-slide-toggle-font-size SlideToggle font-size
--b-slide-toggle-height SlideToggle height
--b-slide-toggle-inner-gap Gap between SlideToggle and its text
--b-slide-toggle-label-before-padding Label padding when displayed before the SlideToggle
--b-slide-toggle-ring-color Ring color (used by material)
--b-slide-toggle-thumb-background Thumb background
--b-slide-toggle-thumb-border Thumb border
--b-slide-toggle-thumb-color Thumb color
--b-slide-toggle-thumb-offset Thumb offset from the start (left)
--b-slide-toggle-thumb-size SlideToggle thumb size (unchecked)
--b-slide-toggle-width SlideToggle width
Checked
--b-slide-toggle-checked-background Background when checked
--b-slide-toggle-checked-border-color Border color when checked
--b-slide-toggle-checked-hover-background Background when checked and hovered
--b-slide-toggle-checked-hovered-thumb-background Thumb background when checked and hovered
--b-slide-toggle-checked-ring-color Ring color when checked (used by material)
--b-slide-toggle-checked-thumb-background Thumb background when checked
--b-slide-toggle-checked-thumb-border Thumb background when checked
--b-slide-toggle-checked-thumb-offset Thumb offset when checked
--b-slide-toggle-checked-thumb-size SlideToggle checked thumb size
Disabled
--b-slide-toggle-disabled-background Background when disabled
--b-slide-toggle-disabled-opacity Opacity when disabled
--b-slide-toggle-disabled-thumb-background Thumb background when disabled
Hovered
--b-slide-toggle-hovered-thumb-background Thumb background when hovered
type: slidetoggle

Source path

Core/widget/SlideToggle.js

Contents