Skip to main content

Widget

Enum Widget 

Source
#[repr(C)]
pub enum Widget {
Show 38 variants Text { content: String, style: TextStyle, }, Image { source: String, shape: ImageShape, ratio: ImageRatio, }, Badge { label: String, tone: Tone, }, Avatar { source: String, status: Option<Tone>, }, PdfView { url: String, }, Video {
Show 17 fields url: String, id: String, playing: bool, seek_to_ms: i64, controls: bool, looping: bool, muted: bool, on_ended: Option<String>, poster: Option<String>, start_at_ms: i64, captions: Vec<Caption>, rate: f32, volume: f32, urls: Vec<String>, start_index: i64, seek_index: i64, allow_pip: bool,
}, WebView { url: String, }, Map { id: String, center_lat: f64, center_lng: f64, zoom: f64, markers: Vec<MapMarker>, style_url: Option<String>, interactive: bool, }, Rating { value: u32, max: u8, on_rate: Option<Vec<String>>, }, ColorDot { color: ProjectColor, }, Divider, Progress { value: Option<f32>, }, Skeleton, Chart { series: Vec<ChartSeries>, labels: Vec<String>, style: ChartStyle, axis: bool, legend: bool, }, RegionChart { regions: Vec<ChartRegion>, ticks: Vec<ChartTick>, x_max: f32, y_max: f32, ref_lines: Vec<ChartRefLine>, bracket: Option<ChartBracket>, legend: Vec<ChartLegendItem>, }, Calendar { year: u32, month: u8, title: String, weekday_labels: Vec<String>, leading_blanks: u8, selected: Option<u8>, on_day: Vec<String>, markers: Vec<u8>, }, SwipeAction { child: Box<Widget>, actions: Vec<SwipeButton>, }, LazyList { children: Vec<Widget>, on_load_more: Option<String>, loading: bool, has_more: bool, on_refresh: Option<String>, refreshing: bool, }, Spacer { size: Spacing, }, Row { children: Vec<Widget>, }, Column { children: Vec<Widget>, }, Card { child: Box<Widget>, style: CardStyle, on_press: Option<String>, on_long_press: Option<String>, }, Box { children: Vec<Widget>, align: BoxAlign, scrim: bool, }, Grid { children: Vec<Widget>, }, Scroller { children: Vec<Widget>, edge_fade: bool, }, Split { primary: Box<Widget>, detail: Box<Widget>, show_detail: bool, on_back: Option<String>, }, A11y { child: Box<Widget>, label: String, hint: Option<String>, role: Option<A11yRole>, }, Button { label: String, style: ButtonStyle, on_press: String, tone: Tone, icon: Option<Icon>, wide: bool, }, IconButton { icon: Icon, on_press: String, }, Chip { label: String, selected: bool, on_press: String, }, TextField { id: String, placeholder: String, value: String, kind: FieldKind, error: Option<String>, }, SearchField { id: String, placeholder: String, value: String, }, Segmented { segments: Vec<Segment>, }, Toggle { id: String, label: String, value: bool, }, Checkbox { id: String, label: String, value: bool, }, Slider { id: String, value: i32, max: i32, }, Stepper { value: i32, on_decrement: String, on_increment: String, }, Scaffold { title: String, body: Box<Widget>, tabs: Vec<Tab>, back: Option<String>, dark_mode: bool, theme: Option<Theme>, fab: Option<Fab>, sheet: Option<Sheet>, on_refresh: Option<String>, refreshing: bool, route: String, depth: u32, },
}
Expand description

The app-agnostic widget tree the shell renders. Fixed across all apps.

Variants§

§

Text

Fields

§content: String
§

Image

Fields

§source: String
§

Badge

Fields

§label: String
§tone: Tone
§

Avatar

A circular avatar image with an optional colored status dot.

Fields

§source: String
§status: Option<Tone>
§

PdfView

An in-app PDF viewer showing the document at url (a remote https URL or a local file URI). Each shell uses its native renderer — PDFKit on iOS, a paged PdfRenderer on Android, an <iframe> on web — so the app only supplies the URL (e.g. a backend-generated report). Fills its width; give it room (place in a sized container).

Fields

§

Video

An in-app native video player for the stream/file at url (MP4 everywhere; HLS .m3u8 on iOS/Android natively + Safari on web; or a local file URI). Native player per shell — AVPlayer (iOS), Media3/ExoPlayer (Android), a <video> element (web). Controllable: playing drives play/pause (app-owned, like a Toggle); set seek_to_ms to jump (the shell seeks when the value CHANGES; -1 = no seek). The shell reports the current position ~once/second via Action::Input { id, value: Int(position_ms) } (handle it in [MobilerApp::input]), and fires on_ended when the clip finishes. controls shows the native transport bar; looping restarts on end; muted starts muted (needed for reliable autoplay). Fills its width; give it room.

v2 fields: poster shows a thumbnail image before the first play; start_at_ms resumes at an offset (applied once on load, -1 = start). captions adds subtitle tracks (see Caption). rate sets playback speed (1.0 = normal) and volume the level (0.01.0). For a playlist, set urls (non-empty takes precedence over url) with start_index; the shell auto-advances and reports the current track ~as it changes via Action::Input { id: "{id}.index", … }, and seek_index jumps to a track when it CHANGES (-1 = none). The shell also reports "{id}.duration", "{id}.state" (0 idle / 1 buffering / 2 ready-paused / 3 playing / 4 ended) and "{id}.buffered" via the same Input path (handle them in [MobilerApp::input]). Set allow_pip to enable Picture-in-Picture (the shell adds a PiP affordance).

Fields

§playing: bool
§seek_to_ms: i64
§controls: bool
§looping: bool
§muted: bool
§on_ended: Option<String>
§poster: Option<String>
§start_at_ms: i64
§captions: Vec<Caption>
§rate: f32
§volume: f32
§urls: Vec<String>
§start_index: i64
§seek_index: i64
§allow_pip: bool
§

WebView

Displays the web page / embedded player at url in a native web view — WKWebView on iOS, android.webkit.WebView on Android, an <iframe> on web. General-purpose: docs, dashboards, or a hosted player embed (e.g. a Bunny.net / YouTube embed URL, which brings its own captions/quality/thumbnails). JavaScript and inline media autoplay are enabled so hosted players work. This is NOT the default way to play video — use Widget::Video for a controllable native player. Fills its width; give it room (place in a sized container).

Fields

§

Map

An interactive map (a “live native view” like Widget::Video): iOS MapKit, Android MapLibre Native, web MapLibre-GL — no API key. The app drives the camera (center_lat/center_lng/zoom) and markers; the user pans/zooms when interactive. Taps report back via Action::Input: a map tap → { id: "{id}.tap", value: Text("lat,lng") }, a marker tap → { id: "{id}.marker", value: Text(marker.id) } (handle in [MobilerApp::input] by id-suffix). style_url selects the MapLibre vector style on Android/web (None → a free default); iOS MapKit uses Apple Maps and ignores it. Fills its width; give it a height (place in a sized container).

Fields

§center_lat: f64
§center_lng: f64
§zoom: f64
§markers: Vec<MapMarker>
§style_url: Option<String>
§interactive: bool
§

Rating

A star rating. value is in tenths (e.g. 48 = 4.8 of max stars). When on_rate is set (one token per star), the stars are tappable — star i fires on_rate[i].

Fields

§value: u32
§max: u8
§on_rate: Option<Vec<String>>
§

ColorDot

Small non-interactive colored dot — a project/identity hint.

Fields

§

Divider

§

Progress

Progress indicator: value 0.0–1.0 for a determinate bar, None for an indeterminate spinner.

Fields

§value: Option<f32>
§

Skeleton

Shimmer placeholder shown while content loads.

§

Chart

A data chart drawing one or more named series in the given style (see ChartStyle). labels (optional) annotate the x-axis for cartesian styles. axis shows y gridlines + tick values (cartesian only); legend shows a series swatch+name row. Non-interactive.

Fields

§labels: Vec<String>
§axis: bool
§legend: bool
§

RegionChart

A variable-width stacked-region (“Marimekko” / coverage-gap) chart: regions are arbitrary colored rectangles in the [0, x_max] × [0, y_max] plane (each with an in-cell label), ticks annotate the irregular x-axis, ref_lines are horizontal target/max lines with right-edge chips, bracket is an optional right-side range annotation, and legend names the colors. The app supplies all geometry; shells map domain→pixels. Non-interactive.

Fields

§regions: Vec<ChartRegion>
§x_max: f32
§y_max: f32
§ref_lines: Vec<ChartRefLine>
§

Calendar

An inline month calendar. The core pre-computes everything locale-dependent so shells only draw: title (e.g. “Septembar 2026”), the 7 weekday_labels in column order (week start first), and leading_blanks (empty cells before day 1). on_day[d-1] fires when day d is tapped (length = days in the month); selected highlights a day. markers is empty (no markers) or one level per day, 0..=3, drawn as that many small dots under the day number.

Fields

§year: u32
§month: u8
§title: String
§weekday_labels: Vec<String>
§leading_blanks: u8
§selected: Option<u8>
§on_day: Vec<String>
§markers: Vec<u8>
§

SwipeAction

A list row that reveals trailing actions on horizontal swipe (each tappable). On web the actions render inline as a trailing button row (no gesture).

Fields

§child: Box<Widget>
§actions: Vec<SwipeButton>
§

LazyList

A scrollable list for long/paged feeds, with shell-detected events at both ends: the bottom on_load_more fires when the user scrolls near the end (infinite scroll), the top on_refresh fires on pull-to-refresh. loading/refreshing/has_more are app-owned: set loading while a page loads (shell shows a spinner, stops firing), has_more=false when exhausted, and refreshing while a pull-refresh runs. The app appends to children on each load-more. on_refresh is set via with_refresh.

Fields

§children: Vec<Widget>
§on_load_more: Option<String>
§loading: bool
§has_more: bool
§on_refresh: Option<String>
§refreshing: bool
§

Spacer

Fields

§size: Spacing
§

Row

Fields

§children: Vec<Widget>
§

Column

Fields

§children: Vec<Widget>
§

Card

Card; tappable when on_press is set. Fires on_long_press (when set) on a press-and-hold (web: a ~500 ms pointer-hold; iOS: onLongPressGesture; Android: combinedClickable’s onLongClick).

Fields

§child: Box<Widget>
§on_press: Option<String>
§on_long_press: Option<String>
§

Box

Z-stack: children layered back-to-front, positioned by align. With scrim, the first child is a background image, darkened for legibility, and the rest render on top in light content.

Fields

§children: Vec<Widget>
§align: BoxAlign
§scrim: bool
§

Grid

Fixed 2-column grid; children flow left-to-right, top-to-bottom.

Fields

§children: Vec<Widget>
§

Scroller

Horizontally scrolling row. edge_fade fades the trailing edge (plus trailing room so the last item clears the fade at scroll-end) to hint there is more to scroll.

Fields

§children: Vec<Widget>
§edge_fade: bool
§

Split

Two-pane master-detail. On a wide screen (tablet / landscape — the shell’s regular size class) primary and detail render side-by-side; on a compact screen (phone) it shows ONE pane: primary until show_detail is set (the app sets it when a row is selected), then detail with a back chevron that fires on_back (the app clears its selection). On wide, show_detail/on_back are ignored — both panes stay visible, so detail should show a placeholder until something is selected.

Fields

§primary: Box<Widget>
§detail: Box<Widget>
§show_detail: bool
§on_back: Option<String>
§

A11y

Accessibility wrapper: presents child’s subtree as ONE screen-reader element named by label (so an unlabeled IconButton/Image gets a name, or a Card’s children group into one announced element). hint describes what activation does; role is the control type. Shell-applied: iOS accessibilityLabel/Hint/Traits, Android contentDescription/role/heading, web aria-label/role.

Fields

§child: Box<Widget>
§label: String
§

Button

A tappable button. tone recolors it (Neutral = the brand/primary look; Danger = the error color pair for destructive actions). icon draws a leading glyph; wide stretches it to the available width.

Fields

§label: String
§on_press: String
§tone: Tone
§icon: Option<Icon>
§wide: bool
§

IconButton

Fields

§icon: Icon
§on_press: String
§

Chip

Fields

§label: String
§selected: bool
§on_press: String
§

TextField

A text input. kind selects keyboard / secure entry / multiline (see FieldKind); error, when Some, shows an inline validation message below the field and marks it invalid. Emits Input { id, Text }.

Fields

§placeholder: String
§value: String
§

SearchField

A search input (leading magnifier, pill shape); emits Input { id, Text } like TextField.

Fields

§placeholder: String
§value: String
§

Segmented

A single-choice segmented control — exclusive options in a pill (e.g. Men/Women/Kids).

Fields

§segments: Vec<Segment>
§

Toggle

Fields

§label: String
§value: bool
§

Checkbox

Fields

§label: String
§value: bool
§

Slider

Continuous 0..=max slider; emits Input { id, Int }.

Fields

§value: i32
§max: i32
§

Stepper

Numeric stepper with −/+ controls carrying their own events.

Fields

§value: i32
§on_decrement: String
§on_increment: String
§

Scaffold

App shell: a top bar (title + optional back), a scrollable body, and bottom-nav tabs. dark_mode is theme-as-data — the shell themes the whole app from it.

route + depth drive navigation: the shell animates the body when route (the current screen’s identity) changes — slide for push/pop (direction from whether depth grew or shrank), crossfade for a lateral move at the same depth — and wires the system back button to back.

Fields

§title: String
§body: Box<Widget>
§tabs: Vec<Tab>
§dark_mode: bool
§theme: Option<Theme>

App branding (brand color, corner, density, font). None = framework defaults (no visual change) — theme-as-data, the visual twin of dark_mode.

§fab: Option<Fab>

Optional floating action button (raised primary action over the body).

§sheet: Option<Sheet>

Optional modal bottom sheet over the body (a scrim + a panel from the bottom).

§on_refresh: Option<String>

Pull-to-refresh: when set, the body is pull-refreshable and fires this event on pull. The app owns refreshing — set it true when the pull fires, clear it when the async reload completes (the shell shows a spinner while it’s true).

§refreshing: bool
§route: String
§depth: u32

Trait Implementations§

Source§

impl Clone for Widget

Source§

fn clone(&self) -> Widget

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Widget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Widget

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Widget, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'ʄ> Facet<'ʄ> for Widget

Source§

const SHAPE: &'static Shape

The shape of this type, including: whether it’s a Struct, an Enum, something else? Read more
Source§

impl Serialize for Widget

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.