Expand description
Starter widget set. Composite widgets should be plain functions over these.
A blanket impl<W: Widget> From<W> for Element is rejected by coherence, so
each widget opts in next to its definition. Third-party widgets can do the
same or use Element::new.
Structs§
- Builder
- Subtree built from the state an async source writes. The source starts on
first build, restarts with fresh state when
depschange, and is dropped (cancelled) with the widget. - Button
- A tappable box built by
button; see there. - Column
- One table column: a header, a cell builder, and optionally a sort order.
- Container
- Flex box with optional rounded, bordered, shadowed background.
- Dropdown
- Picks one of
labels: shows the selected one and lists them all on tap. - Expanded
- Keys of the expanded nodes; view state, kept apart from the model.
- Icon
- A
Shapedrawnsizepx square in one color; a button withon_click. - Image
- A bitmap built by
image; see there. - Label
- A run of text built by
text; see there. - List
- Virtualized vertical list: builds only the rows near the viewport, keeps
the first visible row in place across rebuilds, and slides rows in, out
and to new positions by key. Bound its height like a
scroll’s. - OnBack
- Runs
fon Escape or the Android back button, unless an overlay takes it first, and keeps the app open. Leave it out where Back should exit. - OnKey
- Runs
ffor keys pressed while no text field is focused, e.g. arrows and Enter from a keyboard, remote or D-pad. Topmost first: one that handles a key callsEventCx::stopto keep it from those below. - Overlay
- Content floating above the rest of the tree, outside the layout flow.
- Overlays
- Overlays opened from handlers with
Handle<Overlays>::show, each kept until its exit animation ends. - Page
- A screen built by
page. - Progress
- A horizontal bar: one or more fractions filled over a track, or, with none, a segment sweeping across while the length of a wait is unknown.
- Provide
- Makes
Tavailable to every descendant throughScope::get, e.g. a handle to external state or a service a builder starts work from. - Radio
- One option of a group: a ring before
child, filled whenselected. The whole row is the tap target. - Scroll
- Scroll view; drag (touch, flings on release) or wheel. Children are clipped.
- Seen
- The notifier version a
watchlast built from. - Segmented
- A row of options with a sliding indicator under
selected. - Shown
- One overlay shown through
Overlays, passed to its builder. - Slider
- Controlled horizontal slider over
range: showsvalue, reports drags viaon_change. Tapping the track jumps there. - Snapshot
- What an async source has produced so far, and whether it has finished.
- Spinner
- A spiral for a wait of unknown length, thin outside and thick at the centre: it draws in from the outer end, then retracts the same way.
- Stateful
- Widget with local state
S, kept across rebuilds by tree position or key. Handlers change it withcx.update(handle, |s| ..), which rebuilds the subtree. - Table
Sort - Column and direction a table is sorted by.
- Text
Input - Single-line controlled text field: shows
value, reports edits viaon_change. - Toggle
- Controlled on/off switch: shows
on, reports taps viaon_change.
Traits§
Functions§
- backdrop
- Fills the whole screen with
child, system bars included, under the layers that come after it, e.g. a map below translucent bars. - badge
labelover the top right corner ofchild, such as a count; it takes no layout space. In a column it stretches like any child, so the corner is the column’s.- bottom_
sheet - Modal panel along the bottom edge, full width.
- button
- Tappable box around
child;on_clickruns on a release inside it. Text in it morphs to bold while pressed. - chip
- A small rounded label; restyle with
.bgand.content. - choice_
chip - A chip to tap, filled while
selected; handle it with.on_click. - column
- Lays
childrenout top to bottom. - container
- A single child with optional background, radius, border and shadow.
- dialog
- Modal card centered over the dimmed window.
- drawer
- Modal full-height panel along the left edge.
- dropdown
- A dropdown over
labelsshowinglabels[selected]; the menu floats below it. - future_
builder - Rebuilds once
futureresolves.futuregets the providers in scope. - heading
- Bold text sized for a
pagetitle. - icon
shapeas a 24 px icon.- icon_
button - A borderless button showing
shape: the icon shrinks while pressed and springs back past its size on release. Padded to a comfortable touch target. - image
bitmapstretched over the widget’s box. Its natural size is one logical pixel per bitmap pixel, and a box sized on one axis keeps the aspect ratio.- list
- A virtualized list of
model’s items, each drawn byrow. - on_back
- Handles Back for the screen it’s placed in; see
OnBack. - on_key
- Handles keys for the screen it’s placed in; see
OnKey. - overlay
- Covers the window; place
childin it withalignandjustify. - overlays
- Hosts
contentand the overlays its handlers show through the handle. - page
- A screen: a header row (a back or menu button, then
title) above the body, padded and filling its parent.titleis any widget: aheading, or tabs. - popup
- Floats
childjust below its parent, at least as wide. - progress
- A bar filled to
valuein 0..=1; changes ease in. - provide
childwithvaluein its scope; seeProvide.- radio
- One choice of a group: a ring, filled when
selected, and a label. - row
- Lays
childrenout left to right. - screen
- Covers the whole screen, system bars included; place
childin it withalignandjustify, and pad it by [crate::insets] to keep its content clear of the bars. - scroll
- Vertical scroll view: wheel, drag and fling, clipping
childto its box.horizontalmakes it scroll sideways instead. - segmented
- Pill-shaped segmented button with equal-width options.
- slider
- Thumb on a track for a value in
range; tap to jump, drag to follow. - snackbar
- Short message at the bottom of the window for four seconds after it
enters the tree. Shown through
Overlaysit waits for earlier ones to leave and is removed after; in a plain tree give it a newkeyto show it again. - spacer
- Flexible empty space;
spacer().grow(1.)pushes siblings apart. - spinner
- A 24 px spinner.
- stacked_
progress - Several fractions in one bar, e.g. played over buffered, or tasks running at different speeds. Smaller values are drawn on top, so each shows.
- stateful
- Builds a subtree from local state
S, kept across rebuilds. - stateful_
with statefulstarting frominit, e.g. a form over existing data.initruns once; give the element a newkeyto start over from other data.- stream_
builder - Rebuilds from a stream’s items, collected into
S(aVec,String, …).streamgets the providers in scope. - table
model’s items as rows ofcolumns, under a header that sorts by the sortable ones. Rows are a virtualizedlist; bound its height the same way.- tabs
- Tab bar with an underline; the app shows the selected tab’s content. Each tab is as wide as its label, plus an equal share of the spare width; the selected label turns bold, morphing glyph by glyph.
- text
- A run of text, wrapped at spaces to the available width.
- text_
input - Single-line editable text showing
value; edits arrive inon_change. - toggle
- On/off switch;
on_changegets the new value. - tooltip
- Shows
tipabovechildwhile the pointer is over it. - tree_
view model’s nodes as an indented, virtualized list; the arrow before a node with children expands or collapses it.rowdraws the rest of each line.- wait_
bar - A bar for a wait of unknown length: a segment sweeps across, looping.
- watch
- Rebuilds
build’s subtree each timenotifieris notified, from any thread. Unlike a stream, it can’t run dry: restarts and several watchers of one notifier all keep working.