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

ValueDescription
autoChoose based on widget size
horizontalHorizontal switch
verticalVertical 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.

PartDescription
mainThe background track: background properties. padding shrinks the indicator.
indicatorThe fill that shows the on/off state: background properties. Use the 'checked' state (e.g. indicator|checked) for the ON color.
knobThe 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.

PropertyTypeDescription
orientationenum:lv_switch_orientationSet switch orientation

Last updated on

On this page