Skip to content

Search

Documentation

widget

A HUD element drawn every frame: kind picks label, button, panel and more, anchor places it in design pixels. A click on one is its node's pointer_click…

On this page

ui · 57 properties · UI

A HUD element drawn every frame: kind picks label, button, panel and more, anchor places it in design pixels. A click on one is its node's pointer_click, which a bindings row or its script's on_pointer_click answers; a label, a panel or an image senses a click only where one is heard.

In a scene, widget is the node key that applies it. A script reaches each property below as a field on node.widget: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.widget.get() and node.widget.set(table).

Properties

property type default description
absolute bool false Take this child out of its container's run and place it by inset against the container's box inside its border, drawn in its turn among its siblings; a root ignores it
align_self enum auto Where this child sits across its container's direction; auto takes the container's align_items One of auto, start, center, end, stretch, baseline.
anchor enum top_left Corner, edge or middle the offset is measured from: of the surface for a root, of the parent's box inside a stack; fill takes the whole of it less inset One of top_left, top_right, bottom_left, bottom_right, center, center_left, center_right, center_top, center_bottom, fill, fill_top, fill_bottom, fill_left, fill_right, fill_across, fill_down.
announce bool false A screen reader reads its text out as it arrives and as it changes, as a status line
aspect_ratio float 0 Width over height, kept where the layout decides only one of them; 0 keeps none At least 0.
basis float -1 The size this child starts from along its container's direction, before grow and shrink, in design pixels; below zero is 0 for one that grows and its own size otherwise
border vec4 [0,0,0,0] The width of this widget's outline on each side, left, top, right and bottom, in design pixels: the layout keeps it clear inside the edge as it keeps padding, and the stroke is painted in exactly that band. All zero leaves the stroke at the theme's stroke_width, over the padding
constrain bool false Keep a movable root inside its surface while it is dragged
context string — Name of a menu node whose rows open at the pointer on a right click or a long press; give that menu visible = false to show no button of its own
corner_radius float -1 Corner radius in design pixels, a progress_bar's and an image's included; below zero takes the theme's own, which for a button is as round as its text is tall
cursor enum arrow The pointer's shape while it is over the widget: hand over anything that opens on a click, none to hide it; arrow is the platform's own One of arrow, none, hand, text, vertical_text, cross, cell, wait, progress, help, context_menu, move, grab, grabbing, alias, copy, no_drop, forbidden, all_scroll, resize_x, resize_y, resize_n, resize_e, resize_s, resize_w, resize_ne, resize_nw, resize_se, resize_sw, resize_nesw, resize_nwse, resize_col, resize_row, zoom_in, zoom_out.
dashed bool false Draw the outline in dashes, as a guide over a picture is drawn, rather than whole; square at the corners
enabled bool true Off, the widget is greyed out and swallows its clicks
fade_in bool false Fade a root in as it appears, over egui's fade time
fill string — What is painted behind this widget, an image's picture included, as #rrggbb or a name from the theme's [colors]; empty takes the theme's own
focusable bool true Let focus land here. A widget nothing can activate is never focused whatever this says; set it false to skip one that could be
font asset · font — The face it draws in, and how: a face file such as fonts/Inter.ttf, or a font asset. Empty takes the theme's default font
font_size float 0 Text size in design pixels; 0 takes the size the role or the kind carries At least 0.
font_style enum normal Upright, the family's italic face, or the upright face slanted; a family with no italic is slanted either way One of normal, italic, oblique.
font_weight int 400 Weight on the CSS scale, resolved against the faces the project ships: 400 regular, 700 bold Range 100–900.
grow float 0 Share of the leftover space a container hands out along its own direction; 0 takes only what this widget asks for At least 0.
height float 0 Panel height in design pixels; 0 sizes to content At least 0.
height_percent float 0 Height as a percentage of the container's box inside its padding; 0 leaves it to height, which a stated percentage wins over At least 0.
hide_narrower float 0 Not drawn while the room is narrower than this many design pixels. The room is the nearest container that states a size or grows, and the screen for a root: a minimum in numbers, where the class words are not fine enough. Zero is no line At least 0.
hide_shorter float 0 Not drawn while the room is shorter than this many design pixels. Zero is no line At least 0.
hide_taller float 0 Not drawn while the room is this tall or taller, in design pixels. Zero is no line At least 0.
hide_wider float 0 Not drawn while the room is this wide or wider, in design pixels: a control only a small space wants. Zero is no line At least 0.
inset vec4 [0,0,0,0] Left, top, right and bottom margins a root with anchor = "fill" keeps from its surface, and how far an absolute child sits in from each edge of its container inside its border, where a side below zero is left free; in design pixels
interactive bool true Off, the pointer passes through to the scene: the widget is drawn, never hovered or clicked, and ui.wants_pointer() stays false over it. A full-screen container over the world wants this
kind enum label The HUD element the widget layer draws One of label, button, panel, row, column, scroll, tabs, image, text_field, text_area, checkbox, switch, color_picker, dropdown, menu, list, tree, table, slider, number_field, progress_bar, grid, fold, dialog, window, separator, code, stack.
margin vec4 [0,0,0,0] Space outside this widget's edge that its container keeps clear, left, top, right and bottom, in design pixels; below zero lets a neighbour over it
max_height float 0 Largest height a container may give this widget, and a resizable window be dragged to, in design pixels; 0 is no limit At least 0.
max_width float 0 Largest width a container may give this widget, and a resizable window be dragged to, in design pixels; 0 is no limit At least 0.
min_height float 0 Smallest height a container may give this widget, and a resizable window be dragged to, in design pixels At least 0.
min_width float 0 Smallest width a container may give this widget, and a resizable window be dragged to, in design pixels At least 0.
movable bool false Let a drag move this root and write its x and y: a window by its title bar, any other root by its whole box where no child takes the press
neighbour_down string — The same pointing down
neighbour_left string — The same pointing left
neighbour_right string — The same pointing right
neighbour_up string — The widget focus goes to when an arrow, a stick or a d-pad points up from this one, by node name; empty leaves it to where the widgets were drawn
on_top bool false A root drawn above every root that is not, as a message read over whatever is on screen
padding vec4 [-1,-1,-1,-1] Space inside the widget's edge, in design pixels: one number for every side, or left, top, right and bottom. A container keeps it round its children, a button and a label round their text, and every other kind in its box. A side below zero takes the theme's (padding_x across and padding_y down, else padding), else 8 round a panel, 12 either side of a button's or menu's caption and 0 elsewhere; a stated zero is no space at all. On a text_field, text_area or code it is the margin round the text, where below zero takes egui's
role string — A [roles.<name>] entry of the widget's theme, taken over its kind's own style; the one place a look is named rather than spelled
safe_area flags ["left","top","right","bottom"] The edges this root keeps clear of what a notch, a status bar or a home bar covers. A fill root's own colour still reaches the edge, and one with no children is a backdrop and reaches it whole One of left, top, right, bottom.
shrink float -1 Share of the shortfall this child gives up when its container is too small along its direction; below zero is 1 for one that grows and 0 otherwise
stroke string — The outline around this widget, as #rrggbb or a name from the theme's [colors]; empty takes the theme's own
text string — Label or button caption
text_color color [0,0,0,0] Text color; fully transparent takes the theme's colour for this widget's role or kind, and failing that a near-white
text_key string — A localization key drawn in place of text, re-read every frame so a locale switch shows at once
text_style asset · text_style — How it is dressed past its font: line height and spacing, the lines drawn with the glyphs, an outline and a shadow. Empty draws it plain
theme asset · widget_theme — How this widget and everything under it is drawn; inherited from the nearest ancestor that names one
tooltip string — Text shown after the pointer rests on the widget; still shown while enabled is off, which is where it says why
whole_window bool false Whether this root draws over the whole window, whatever ui.set_widget_layer says: what an editor's own chrome does. Ignored on a child.
width float 0 Panel width in design pixels; 0 sizes to content At least 0.
width_percent float 0 Width as a percentage of the container's box inside its padding; 0 leaves it to width, which a stated percentage wins over At least 0.
x float 16 Horizontal offset from the anchor, in design pixels
y float 16 Vertical offset from the anchor, in design pixels

Asset types this component references: font, text_style, widget_theme.

Are you sure?