Button (lv_button)

A clickable Base Widget with defaults tuned for buttons (not scrollable, added to the default group, sized to fit its child).

Edit on GitHub

Overview

A Button is a clickable base widget with three defaults tuned for its role: not scrollable, added to the default group, and LV_SIZE_CONTENT for both axes so it hugs its label child.

States

The two button-relevant states are LV_STATE_CHECKED (toggled by a click when the LV_OBJ_FLAG_CHECKABLE flag is set) and LV_STATE_DISABLED (greys out the button and ignores input).

Styling

A button has only LV_PART_MAIN but picks up the full base-widget style stack: bg_color, radius, border_*, outline_*, shadow_*, pad_*, text_color.

State-aware styling is the headline feature: attach separate styles with selector="pressed", "checked", "focused", or "disabled" so the button changes look as the user interacts with it.

Events

Learn more about Events emitted by all Widgets.

Keys

Note that the state of LV_KEY_ENTER is translated to LV_EVENT_PRESSED, LV_EVENT_PRESSING and LV_EVENT_RELEASED etc.

Learn more about Keys.

Last updated on

On this page