Use the switch input component for boolean-like options, such as enabling/disabling notifications, or for settings that can be toggled between two states.
<bp-form-grouplayout="vertical"><bp-fieldset><label>label</label><label>switch 1</label><bp-switchchecked></bp-switch><label>switch 2</label><bp-switch></bp-switch><label>switch 3</label><bp-switch></bp-switch><bp-field-message>message text</bp-field-message></bp-fieldset><!-- disable all controls within group or set disabled on input individually --><bp-fieldsetdisabled><label>disabled</label><label>switch 1</label><bp-switchcheckeddisabled></bp-switch><label>switch 2</label><bp-switchdisabled></bp-switch><label>switch 3</label><bp-switchdisabled></bp-switch><bp-field-message>message text</bp-field-message></bp-fieldset><bp-fieldsetstatus="error"><label>error</label><label>switch 1</label><bp-switchchecked></bp-switch><label>switch 2</label><bp-switch></bp-switch><label>switch 3</label><bp-switch></bp-switch><bp-field-messagestatus="error">message text</bp-field-message></bp-fieldset><bp-fieldsetstatus="success"><label>success</label><label>switch 1</label><bp-switchchecked></bp-switch><label>switch 2</label><bp-switch></bp-switch><label>switch 3</label><bp-switch></bp-switch><bp-field-messagestatus="success">message text</bp-field-message></bp-fieldset></bp-form-group>
The switch input component should have an accessible label that describes its purpose and state.
The switch input component should be keyboard accessible, allowing users to use the keyboard to select and activate the switch.
The switch input component should also have clear visual indication of its state (e.g. switched on or off), and change state when activated by either the mouse or keyboard.
bp-switch
Events
Name
Types
Description
input
InputEvent
occurs when the value changes
change
InputEvent
occurs when the value changes
Properties
Name
Types
Description
value
string | number | FormData | File
determines initial value of the control
checked
boolean
determines whether element is checked
formAssociated
boolean
disabled
boolean
determines if element is mutable or focusable
required
boolean
indicates that the user must specify a value for the input before the owning form can be submitted
readonly
boolean
makes the element not mutable, meaning the user can not edit the control
multiple
boolean
determines he form control accepts one or more values
autocomplete
string
provide automated assistance in filling out form field values, and guidance to the browser as to the type of information expected in the field
type
string
string specifying the type of control to render
name
string
represents the name of the current
pattern
string
regular expression the form control's value should match
placeholder
string
defines a short hint to help the user with data entry when a form control has no value
minLength
number
defines minimum number of characters
maxLength
number
defines maximum number of characters
min
number
defines the most negative value in the range of permitted values
max
number
defines the greatest value in the range of permitted values
size
number
determines number of characters
valueAsNumber
composedLabel
focus
reset
Attributes
Name
Types
Description
value
string | number | FormData | File
determines initial value of the control
checked
boolean
determines whether element is checked
disabled
boolean
determines if element is mutable or focusable
required
boolean
indicates that the user must specify a value for the input before the owning form can be submitted
readonly
boolean
makes the element not mutable, meaning the user can not edit the control
multiple
boolean
determines he form control accepts one or more values
autocomplete
string
provide automated assistance in filling out form field values, and guidance to the browser as to the type of information expected in the field
type
string
string specifying the type of control to render
pattern
string
regular expression the form control's value should match
placeholder
string
defines a short hint to help the user with data entry when a form control has no value
minLength
number
defines minimum number of characters
maxLength
number
defines maximum number of characters
min
number
defines the most negative value in the range of permitted values
max
number
defines the greatest value in the range of permitted values