Switch (lv_switch)
A small slider that displays and toggles an on/off value.
Overview
The Switch looks like a small slider and displays — and optionally toggles — an on/off value. It is horizontal by default and becomes vertical when its width is smaller than its height.
Learn more in the LVGL Open documentation.
Enumerations
lv_switch_orientation — Switch orientation
| Value | Description |
|---|---|
auto | Choose based on widget size |
horizontal | Horizontal switch |
vertical | Vertical switch |
Properties
Parts
Style parts of the widget with local style (e.g. style_bg_color-knob="0xff0000") or with style sheets (e.g. <style name="style_knob" selector="knob">). See Styles to learn more.
| Part | Description |
|---|---|
main | The background track: background properties. padding shrinks the indicator. |
indicator | The fill that shows the on/off state: background properties. Use the 'checked' state (e.g. indicator|checked) for the ON color. |
knob | The sliding handle: background, border, shadow and padding properties. |
Properties below are the widget's XML <api>; see API for how properties, parameters and elements work.
| Property | Type | Description |
|---|---|---|
orientation | enum:lv_switch_orientation | Set switch orientation |
Last updated on