Overview
The toggle component, similar to a checkbox, allows you to interact a boolean value.boolean cast to the model property:
Adding icons to the toggle button
Toggles may also use an icon to represent the “on” and “off” state of the button. To add an icon to the “on” state, use theonIcon() method. To add an icon to the “off” state, use the offIcon() method:
Customizing the color of the toggle button
You may also customize the color representing the “on” or “off” state of the toggle. These may be eitherdanger, gray, info, primary, success or warning. To add a color to the “on” state, use the onColor() method. To add a color to the “off” state, use the offColor() method:
Positioning the label above
Toggle fields have two layout modes, inline and stacked. By default, they are inline. When the toggle is inline, its label is adjacent to it:Toggle validation
As well as all rules listed on the validation page, there are additional rules that are specific to toggles.Accepted validation
You may ensure that the toggle is “on” using theaccepted() method:
Declined validation
You may ensure that the toggle is “off” using thedeclined() method: