Style Properties

Every style property usable as a style_* attribute or in a <style> sheet on any widget.

Overview

Every widget supports the style properties below. Use them as local style_<name> attributes (optionally with a -<part> or -<state> selector) or inside a named <style> sheet. See the Styles page for selectors, parts and states.

Position and size

PropertyTypeDescription
xpx|%Horizontal position relative to the parent's content area (px or %). Usually set align or use a layout instead.
ypx|%Vertical position relative to the parent's content area (px or %). Usually set align or use a layout instead.
heightpx|%|contentWidget height: px, % of the parent, or content to shrink-wrap the children.
min_heightpx|%Minimum height the widget may shrink to (px or %). Useful with content sizing.
max_heightpx|%Maximum height the widget may grow to (px or %). Useful with content sizing.
widthpx|%|contentWidget width: px, % of the parent, or content to shrink-wrap the children.
min_widthpx|%Minimum width the widget may shrink to (px or %). Useful with content sizing.
max_widthpx|%Maximum width the widget may grow to (px or %). Useful with content sizing.
lengthpx|%Size of a widget-specific element (e.g. scale tick length, arc/slider knob). Meaning depends on the widget.

Padding and margin

PropertyTypeDescription
pad_topintSpace between the top edge and the content/children (px).
pad_bottomintSpace between the bottom edge and the content/children (px).
pad_leftintSpace between the left edge and the content/children (px).
pad_rightintSpace between the right edge and the content/children (px).
pad_horintShorthand for pad_left and pad_right together (px).
pad_verintShorthand for pad_top and pad_bottom together (px).
pad_allintShorthand for all four paddings at once (px).
pad_rowintGap between rows of children in a flex/grid layout (px).
pad_columnintGap between columns of children in a flex/grid layout (px).
pad_gapintShorthand for both pad_row and pad_column (px).
pad_radialintOn round scales, distance of the tick labels from the scale (px).
margin_topintEmpty space kept above the widget in a layout, pushing neighbors away (px).
margin_bottomintEmpty space kept below the widget in a layout, pushing neighbors away (px).
margin_leftintEmpty space kept left of the widget in a layout, pushing neighbors away (px).
margin_rightintEmpty space kept right of the widget in a layout, pushing neighbors away (px).
margin_horintShorthand for margin_left and margin_right (px).
margin_verintShorthand for margin_top and margin_bottom (px).
margin_allintShorthand for all four margins at once (px).

Geometry

PropertyTypeDescription
radiusintCorner radius (px). 0 = square corners. Default: 0.
radial_offsetintShifts the part radially out from (or into) the center on round widgets such as scales (px). Default: 0.
alignenum:lv_alignAnchor point of the widget within the parent (e.g. center, top_left). x/y then act as offsets from it.
clip_cornerboolClip the content/children to the rounded corners set by radius. Small performance cost. Default: false.
base_direnum:lv_base_dirBase text direction (LTR/RTL/auto). Affects bidirectional text order and which side the vertical scrollbar sits on.

Background

PropertyTypeDescription
bg_colorcolorBackground fill color. Only visible when bg_opa is above 0.
bg_opaopaBackground opacity (0-255 or 0-100%). Default: 0 (transparent) — raise it to reveal bg_color/gradient.
bg_grad_direnum:lv_grad_dirBackground gradient direction: none, hor or ver. Blends bg_color into bg_grad_color. Default: none.
bg_main_stopintPosition where the start color stops fading, 0-255 (0=start, 128=middle, 255=end). Default: 0.
bg_grad_stopintPosition where the end color begins, 0-255. Default: 255.
bg_grad_colorcolorSecond color of the background gradient (used when bg_grad_dir is set).

Background image

PropertyTypeDescription
bg_image_srcimageBackground image (image name or symbol). Drawn over the background color and under the border.
bg_image_tiledboolRepeat (tile) the background image to fill the area instead of drawing it once. Default: false.
bg_image_recolorcolorColor blended onto the background image; intensity set by bg_image_recolor_opa.
bg_image_recolor_opaopaStrength of bg_image_recolor (0-255 or 0-100%). Default: 0 (no recolor).

Border

PropertyTypeDescription
border_colorcolorBorder color. Only visible when border_width is above 0.
border_widthintBorder thickness (px). Drawn inside the bounds, so it doesn't change the widget's size. Default: 0.
border_opaopaBorder opacity (0-255 or 0-100%). Default: 255 (opaque).
border_sideenum:lv_border_sideWhich edges get a border: none/left/right/top/bottom/full (can be ORed). Default: full.
border_postboolDraw the border after the children so it stays on top of them. Default: false.

Outline

PropertyTypeDescription
outline_colorcolorOutline color. Only visible when outline_width is above 0.
outline_widthintOutline thickness (px). Drawn outside the bounds and doesn't affect layout. Default: 0.
outline_opaopaOutline opacity (0-255 or 0-100%). Default: 255 (opaque).
outline_padintGap between the widget's edge and the outline (px); can be negative.

Shadow

PropertyTypeDescription
shadow_widthintShadow blur size (px). Default: 0 (no shadow). Larger spreads a softer shadow.
shadow_colorcolorShadow color. Only visible when shadow_width is above 0.
shadow_opaopaShadow opacity (0-255 or 0-100%). Default: 255 (opaque).
shadow_offset_xintHorizontal shadow offset (px), positive = right. Default: 0.
shadow_offset_yintVertical shadow offset (px), positive = down. Default: 0.
shadow_spreadintGrow (or shrink, if negative) the shadow by this many px before blurring. Default: 0.

Text

PropertyTypeDescription
text_colorcolorText color.
text_opaopaText opacity (0-255 or 0-100%). Default: 255 (opaque).
text_fontfontFont used for the text.
text_alignenum:lv_text_alignHorizontal text alignment: left/center/right/auto (auto follows the base direction).
text_letter_spaceintExtra spacing between characters (px); can be negative.
text_line_spaceintExtra spacing between lines (px); can be negative.
text_decorenum:lv_text_decorText decoration: none, underline or strikethrough.

Image

PropertyTypeDescription
image_opaopaOpacity of images the widget draws (0-255 or 0-100%). Default: 255 (opaque).
image_recolorcolorColor blended onto the image; intensity set by image_recolor_opa.
image_recolor_opaopaStrength of image_recolor (0-255 or 0-100%). Default: 0 (no recolor).

Line

PropertyTypeDescription
line_widthintLine thickness (px). Default: 0 (nothing drawn).
line_colorcolorLine color.
line_opaopaLine opacity (0-255 or 0-100%). Default: 255 (opaque).
line_dash_widthintLength of each dash (px). 0 = solid line.
line_dash_gapintGap between dashes (px). Needs line_dash_width above 0.
line_roundedboolRound the line (and dash) endpoints. Default: false.

Arc

PropertyTypeDescription
arc_widthintArc thickness (px). Default: 0.
arc_colorcolorArc color.
arc_opaopaArc opacity (0-255 or 0-100%). Default: 255 (opaque).
arc_roundedboolRound the arc endpoints. Default: false.
arc_image_srcimageImage drawn along the arc instead of a solid color (e.g. a gradient/textured arc).

Layout

PropertyTypeDescription
layoutenum:lv_layoutLayout engine that positions the children: none, flex or grid.

Flex

PropertyTypeDescription
flex_flowenum:lv_flex_flowHow children flow in a flex layout: row/column, optionally wrapping/reversed. Needs layout=flex.
flex_main_placeenum:lv_flex_alignDistribution of children along the main axis (e.g. start, center, space_between). Default is start.
flex_cross_placeenum:lv_flex_alignAlignment of children on the cross axis (perpendicular to the flow). Default is start.
flex_track_placeenum:lv_flex_alignAlignment of the track(s). Default is start.
flex_growintShare of leftover track space this child claims relative to its siblings. 0 = don't grow.

Grid

PropertyTypeDescription
grid_column_dsc_arraygrid_dsc[LV_GRID_TEMPLATE_LAST]Array of column track sizes, e.g. 20 1fr content. Needs layout=grid.
grid_row_dsc_arraygrid_dsc[LV_GRID_TEMPLATE_LAST]Array of row track sizes, e.g. 20 1fr content. Needs layout=grid.
grid_column_alignenum:lv_grid_alignHow to distribute the columns when the grid has spare horizontal space.
grid_row_alignenum:lv_grid_alignHow to distribute the rows when the grid has spare vertical space.
grid_cell_column_posintOn a grid child: the column index where its cell starts (0-based).
grid_cell_column_spanintOn a grid child: how many columns its cell spans.
grid_cell_x_alignenum:lv_grid_alignOn a grid child: horizontal alignment within its grid cell.
grid_cell_row_posintOn a grid child: the row index where its cell starts (0-based).
grid_cell_row_spanintOn a grid child: how many rows its cell spans.
grid_cell_y_alignenum:lv_grid_alignOn a grid child: vertical alignment within its grid cell.

Misc

PropertyTypeDescription
opaopaOpacity of the whole widget and its children (0-255 or 0-100%). Default: 255 (opaque).
opa_layeredopaLike opa, but composites the widget as one layer so overlapping parts don't show through. Slower. Default: 255.
anim_durationintLength of the widget's built-in animation in ms (e.g. label scroll). Default: 0. Exact effect is widget-specific.
blend_modeenum:lv_blend_modeHow the widget's pixels mix with the background: normal, additive, subtractive, multiply or difference.
transform_widthintEnlarge (or shrink, if negative) the drawn widget horizontally without affecting layout (px).
transform_heightintEnlarge (or shrink, if negative) the drawn widget vertically without affecting layout (px).
translate_xintShift the widget horizontally after layout (px or %); siblings are not affected.
translate_yintShift the widget vertically after layout (px or %); siblings are not affected.
translate_radialintOn round/scale layouts, move the widget toward or away from the parent's center (px).
transform_scale_xintHorizontal zoom: 256 = 100%, 128 = 50%, 512 = 200%. Default: 256 (no scaling).
transform_scale_yintVertical zoom: 256 = 100%, 128 = 50%, 512 = 200%. Default: 256 (no scaling).
transform_rotationintRotation in 0.1° units (450 = 45°, 3600 = 360°). Default: 0. Pivot set by transform_pivot_x/y.
transform_pivot_xintX of the rotation/scale pivot, relative to the widget's top-left corner (px or %). Default: 0.
transform_pivot_yintY of the rotation/scale pivot, relative to the widget's top-left corner (px or %). Default: 0.
transform_skew_xintHorizontal skew in 0.1° units. Not supported by the SW renderer. Default: 0.
transform_skew_yintVertical skew in 0.1° units. Not supported by the SW renderer. Default: 0.
bitmap_mask_srcimageAn A8/L8 image used as an alpha mask: the widget is drawn on a layer and masked by this bitmap.
rotary_sensitivityintScales rotary-encoder/Crown input in 1/256 units: 256 = 1:1, 128 = half, 512 = double. Default: 256.
recolorcolorColor blended over the whole widget and its children; intensity set by recolor_opa.
recolor_opaopaStrength of recolor (0-255 or 0-100%). Default: 0 (no recolor).
blur_radiusintGaussian blur radius applied to the widget (px). Default: 0 (no blur). Has a performance cost.
blur_qualityenum:lv_blur_qualityBlur rendering trade-off: prefer speed or precision.
blur_backdropbooltrue: blur what is behind the widget (frosted-glass effect); false: blur the widget itself. Default: false.
drop_shadow_radiusintBlur radius of the drop shadow (px). Default: 0 (no drop shadow).
drop_shadow_offset_xintHorizontal drop-shadow offset (px). Default: 0.
drop_shadow_offset_yintVertical drop-shadow offset (px). Default: 0.
drop_shadow_colorcolorDrop-shadow color.
drop_shadow_opaopaDrop-shadow opacity (0-255 or 0-100%). Default: 0 (invisible), raise it to show the shadow.
drop_shadow_qualityenum:lv_blur_qualityDrop-shadow rendering trade-off: prefer speed or precision.

Last updated on

On this page