NativeDesktop

Component reference

Every built-in element constructor and its builder methods, generated from nd-components.

This page is generated from the source of crates/nd-components each time the docs build, so it lists exactly what the crate exports. For what each component looks like on each OS, open the Gallery example.

Generated from crates/nd-components/src by nd-docs: 118 element constructors in 31 modules. Each lists the builder methods of the element it returns.

controls

icon_button

pub fn icon_button(id : impl Into<SharedString>, icon : Icon) -> Button

A button showing only icon; the platform's toolbar or borderless style.

separator

pub fn separator() -> Separator
Separator methodDoes
.vertical()

form

form

pub fn form() -> Form

A grouped form. Children are [form_section]s.

Form methodDoes
.title(title : impl Into<SharedString>)A page title above the sections, scrolling with them unless [Form::pin_title].
.pin_title()Keeps the title in place while the rows scroll under it.

form_section

pub fn form_section() -> FormSection

A group of rows under an optional title.

FormSection methodDoes
.title(title : impl Into<SharedString>)
.footer(footer : impl Into<SharedString>)

form_row

pub fn form_row(label : impl Into<SharedString>) -> FormRow

One row: label on the leading side, its single child control on the trailing side.

FormRow methodDoes
.help(help : impl Into<SharedString>)
.id(id : impl Into<SharedString>)

forms/choice

option_index

pub fn option_index(options : &[SharedString], value : &str) -> Option<usize>

The index value names among options: the option's title (exact, then ignoring case), or its index.

select

pub fn select(id : impl Into<SharedString>, options : impl IntoIterator<Item = impl Into<SharedString>>) -> Select
Select methodDoes
.selected(index : usize)
.native(mapping : Mapping)
.horizontal()
.label(label : impl Into<SharedString>)
.on_change(f : impl Fn(&SelectChanged, &mut Window, &mut App) + 'static)

segmented

pub fn segmented(id : impl Into<SharedString>, options : impl IntoIterator<Item = impl Into<SharedString>>) -> Select

A segmented control: the options side by side, one selected.

Select methodDoes
.selected(index : usize)
.native(mapping : Mapping)
.horizontal()
.label(label : impl Into<SharedString>)
.on_change(f : impl Fn(&SelectChanged, &mut Window, &mut App) + 'static)

radio_group

pub fn radio_group(id : impl Into<SharedString>, options : impl IntoIterator<Item = impl Into<SharedString>>) -> Select

Radio buttons, one per option, stacked unless .horizontal().

Select methodDoes
.selected(index : usize)
.native(mapping : Mapping)
.horizontal()
.label(label : impl Into<SharedString>)
.on_change(f : impl Fn(&SelectChanged, &mut Window, &mut App) + 'static)

forms/date

date_picker

pub fn date_picker(id : impl Into<SharedString>, value : CivilDateTime) -> DatePicker
DatePicker methodDoes
.mode(mode : DatePickerMode)
.presentation(presentation : DatePickerStyle)
.min(min : CivilDateTime)
.max(max : CivilDateTime)
.label(label : impl Into<SharedString>)
.on_change(f : impl Fn(&DateChanged, &mut Window, &mut App) + 'static)

color_well

pub fn color_well(id : impl Into<SharedString>, color : Hsla) -> ColorWell
ColorWell methodDoes
.alpha(alpha : bool)
.label(label : impl Into<SharedString>)
.on_change(f : impl Fn(&ColorChanged, &mut Window, &mut App) + 'static)

forms/display

label

pub fn label(text : impl Into<SharedString>) -> Label

Text in one of the system's text styles. text() is the plain run; a label is the control a form or window uses for titles and supporting text.

Label methodDoes
.id(id : impl Into<SharedString>)
.text_style(style : TextStyle)
.secondary()
.tone(tone : LabelTone)
.selectable()
.wraps()
.rich(rich : RichText)Replaces the text with runs of their own style, in the label's text style.
.on_link(handler : impl Fn(&LinkClicked, &mut Window, &mut App) + 'static)Handles a click on a link run; the system no longer opens it.
pub fn link(id : impl Into<SharedString>, title : impl Into<SharedString>) -> Link

A text link. With a url it opens in the default browser; on_click sees every activation.

Link methodDoes
.url(url : impl Into<SharedString>)
.keep_internal()Fires [LinkActivated] only; the app opens what it wants.
.on_click(f : impl Fn(&LinkActivated, &mut Window, &mut App) + 'static)

progress

pub fn progress(value : Option<f32>) -> Progress

A progress bar at value (0 to 1); None shows an indeterminate bar.

Progress methodDoes
.id(id : impl Into<SharedString>)
.circular()
.label(label : impl Into<SharedString>)

spinner

pub fn spinner() -> Progress

The spinning activity indicator.

Progress methodDoes
.id(id : impl Into<SharedString>)
.circular()
.label(label : impl Into<SharedString>)

forms/rows

settings_group

pub fn settings_group(title : impl Into<SharedString>) -> FormSection

A titled group of rows; form_section under its libadwaita name.

FormSection methodDoes
.title(title : impl Into<SharedString>)
.footer(footer : impl Into<SharedString>)

row

pub fn row(title : impl Into<SharedString>) -> FormRow

A row with a title and optional subtitle, holding one trailing control (.child(..)).

FormRow methodDoes
.help(help : impl Into<SharedString>)
.id(id : impl Into<SharedString>)

switch_row

pub fn switch_row(id : impl Into<SharedString>, title : impl Into<SharedString>) -> SwitchRow

A titled row with a switch, controlled like [switch].

SwitchRow methodDoes
.subtitle(subtitle : impl Into<SharedString>)
.checked(checked : bool)
.disabled(disabled : bool)
.on_toggle(f : impl Fn(&Toggled, &mut Window, &mut App) + 'static)
pub fn navigation_row(id : impl Into<SharedString>, title : impl Into<SharedString>, on_activate : impl Fn(&RowActivated, &mut Window, &mut App) + 'static) -> FormRow

A row that navigates somewhere: a disclosure chevron as its control, firing [RowActivated].

FormRow methodDoes
.help(help : impl Into<SharedString>)
.id(id : impl Into<SharedString>)

clamp

pub fn clamp() -> Clamp
Clamp methodDoes
.maximum(maximum : Pixels)

form_field

pub fn form_field(label : impl Into<SharedString>) -> FormField
FormField methodDoes
.help(help : impl Into<SharedString>)
.error(error : Option<impl Into<SharedString>>)Shown in place of the help text while set.
.control(control : impl IntoElement)

button_group

pub fn button_group() -> ButtonGroup

sheet_layout

pub fn sheet_layout(title : impl Into<SharedString>) -> SheetLayout
SheetLayout methodDoes
.footer(button : impl IntoElement)Adds a footer button; add the default action last.

forms/settings

settings_form

pub fn settings_form<T : Settings>() -> AnyElement

The settings form for T. Without a provided handle it shows the defaults, read-only.

forms/text

text_field

pub fn text_field(id : impl Into<SharedString>) -> TextField

A single-line text field.

TextField methodDoes
.secure()
.search()
.leading_icon(icon : Icon, label : impl Into<SharedString>)An icon at the field's leading edge; clicks fire [FieldIconClicked].
.trailing_icon(icon : Icon, label : impl Into<SharedString>)An icon at the field's trailing edge (a reveal or clear button).
.on_icon_click(f : impl Fn(&FieldIconClicked, &mut Window, &mut App) + 'static)

secure_field

pub fn secure_field(id : impl Into<SharedString>) -> TextField

A password field: characters hidden, value never exposed to automation reads.

TextField methodDoes
.secure()
.search()
.leading_icon(icon : Icon, label : impl Into<SharedString>)An icon at the field's leading edge; clicks fire [FieldIconClicked].
.trailing_icon(icon : Icon, label : impl Into<SharedString>)An icon at the field's trailing edge (a reveal or clear button).
.on_icon_click(f : impl Fn(&FieldIconClicked, &mut Window, &mut App) + 'static)

search_field

pub fn search_field(id : impl Into<SharedString>, state : &Entity<TextFieldState>) -> TextField

The platform's search field, bound to state.

TextField methodDoes
.secure()
.search()
.leading_icon(icon : Icon, label : impl Into<SharedString>)An icon at the field's leading edge; clicks fire [FieldIconClicked].
.trailing_icon(icon : Icon, label : impl Into<SharedString>)An icon at the field's trailing edge (a reveal or clear button).
.on_icon_click(f : impl Fn(&FieldIconClicked, &mut Window, &mut App) + 'static)

text_area

pub fn text_area(id : impl Into<SharedString>) -> TextArea

Multi-line text, scrolling inside its frame.

TextArea methodDoes
.min_lines(lines : u16)
.max_lines(lines : u16)Grows with its text up to lines, then scrolls.
.submit_on_return()Return submits ([TextInput::on_submit]); Shift-Return inserts a line break.
.accepts_media()Takes pasted and dropped images and files as events instead of text.
.emoji_picker(request : u64)Opens the system emoji picker whenever request changes; pass a counter the app bumps.
.on_images(f : impl Fn(&ImagesPasted, &mut Window, &mut App) + 'static)
.on_files(f : impl Fn(&FilesDropped, &mut Window, &mut App) + 'static)

combo_box

pub fn combo_box(id : impl Into<SharedString>, options : impl IntoIterator<Item = impl Into<SharedString>>) -> ComboBox

A text field with suggestions.

ComboBox methodDoes
.completes(completes : bool)
.on_select(f : impl Fn(&super::SelectChanged, &mut Window, &mut App) + 'static)The user picked a suggestion; its text arrives as a [TextChanged] too.

forms/toggle

checkbox

pub fn checkbox(id : impl Into<SharedString>, label : impl Into<SharedString>) -> Checkbox

A checkbox with its title beside it.

Checkbox methodDoes
.checked(checked : bool)
.mixed(mixed : bool)
.on_toggle(f : impl Fn(&Toggled, &mut Window, &mut App) + 'static)

switch

pub fn switch(id : impl Into<SharedString>) -> Switch

An on/off switch. Give it a .label(..) when no row title names it.

Switch methodDoes
.checked(checked : bool)
.label(label : impl Into<SharedString>)
.on_toggle(f : impl Fn(&Toggled, &mut Window, &mut App) + 'static)

forms/value

number_text

pub fn number_text(value : f64, digits : Option<u8>) -> String

Formats a number without trailing zeros (0.5, 3), the form automation reads back.

slider

pub fn slider(id : impl Into<SharedString>, value : f32) -> Slider
Slider methodDoes
.range(range : RangeInclusive<f32>)
.step(step : f32)
.ticks(ticks : usize)
.vertical()
.label(label : impl Into<SharedString>)
.drawn()The framework-drawn slider on every OS instead of the native control: it takes every style override (height, radius, colours) the native one cannot express.
.on_change(f : impl Fn(&SliderChanged, &mut Window, &mut App) + 'static)

stepper

pub fn stepper(id : impl Into<SharedString>, value : f64) -> Stepper

Up and down arrows changing value by a step.

Stepper methodDoes
.range(range : RangeInclusive<f64>)
.step(step : f64)
.wraps(wraps : bool)
.with_field(digits : u8)The value in an editable field beside the arrows, with digits decimals.
.label(label : impl Into<SharedString>)
.on_change(f : impl Fn(&StepperChanged, &mut Window, &mut App) + 'static)

glass

glass

pub fn glass() -> Glass

A glass surface. Lays its children out like a div.

Glass methodDoes
.id(id : impl Into<SharedString>)
.variant(variant : GlassVariant)
.tint(tint : impl Into<Hsla>)
.interactive()

glass_group

pub fn glass_group() -> GlassGroup
GlassGroup methodDoes
.spacing(spacing : Pixels)

media/chat

chat_bubble

pub fn chat_bubble(text : impl Into<SharedString>, side : BubbleSide) -> ChatBubble

A message bubble. Its width follows the text up to BUBBLE.max_width.

ChatBubble methodDoes
.id(id : impl Into<SharedString>)
.position(position : RunPosition)
.reactions(reactions : impl IntoIterator<Item = Reaction>)
.time(time : impl Into<SharedString>)The time, shown on hover.
.rich(rich : RichText)Replaces the text with runs of their own style. A link run reports [LinkClicked] (.on_link); text that is all emoji still draws large without a bubble.
.role(role : FillRole)Fills the bubble by meaning instead of by side: FillRole::Success is an SMS message's green. Fill and ink come from the theme.
.on_link(handler : impl Fn(&LinkClicked, &mut Window, &mut App) + 'static)Handles a click on a link run; the system no longer opens it.

initials

pub fn initials(name : &str) -> String

The monogram for name: the first letters of its first and last words, uppercased, or # for a name that is empty or a phone number (drawn as a person glyph).

group_layout

pub fn group_layout(count : usize, size : f32) -> Vec<nd_core::Rect>

Where each person of a group sits inside a size circle: up to four mini avatars [AVATAR_GROUP_SCALE] of it, one row for two, one over two for three, two by two for four.

avatar

pub fn avatar(person : Person, size : f32) -> Avatar

A person's photo, or their initials, in a circle size points across.

Avatar methodDoes
.id(id : impl Into<SharedString>)

avatar_group

pub fn avatar_group(people : impl IntoIterator<Item = Person>, size : f32) -> Avatar

A group's avatar: its first four people clustered in one circle.

Avatar methodDoes
.id(id : impl Into<SharedString>)

chat_row

pub fn chat_row(id : impl Into<SharedString>, message : ChatMessage) -> AnyElement

A message laid out as a thread row: aligned to its side, spaced by its run, the sender's avatar and name in a group, a receipt under it. id keys the row's bubble.

media/composer

composer

pub fn composer(id : impl Into<SharedString>, draft : &Draft) -> Composer

The message field over draft.

Composer methodDoes
.placeholder(placeholder : impl Into<SharedString>)
.disabled(disabled : bool)
.without_attach()No attach button; pasted and dropped files still stage.
.on_event(f : impl Fn(&ComposerEvent, &mut Window, &mut App) + 'static)

media/image

image

pub fn image(source : impl Into<ImageSource>) -> Image

A picture from a path, URL or bytes. Size it with the style; a side left open follows the image's aspect.

Image methodDoes
.id(id : impl Into<SharedString>)
.fit(fit : ImageFit)
.tint(color : impl Into<Hsla>)Draws the picture in color (a theme token), keeping each pixel's alpha.
.contain()Letterboxes instead of cropping.
.size_hint(width : u32, height : u32)
.alt(alt : impl Into<SharedString>)
.still()Shows the first frame of an animation only.
.on_load(f : impl Fn(&ImageLoaded, &mut Window, &mut App) + 'static)
.on_error(f : impl Fn(&ImageFailed, &mut Window, &mut App) + 'static)

image_placeholder

pub fn image_placeholder() -> Image

An image node with no picture yet: the placeholder alone, at the size the style gives.

Image methodDoes
.id(id : impl Into<SharedString>)
.fit(fit : ImageFit)
.tint(color : impl Into<Hsla>)Draws the picture in color (a theme token), keeping each pixel's alpha.
.contain()Letterboxes instead of cropping.
.size_hint(width : u32, height : u32)
.alt(alt : impl Into<SharedString>)
.still()Shows the first frame of an animation only.
.on_load(f : impl Fn(&ImageLoaded, &mut Window, &mut App) + 'static)
.on_error(f : impl Fn(&ImageFailed, &mut Window, &mut App) + 'static)

media/lyrics

rows

pub fn rows(lyrics : &Lyrics) -> Vec<Row>

The rows for lyrics: lines with text in time order, interludes in the long gaps, and word fills for every synced line.

lit_at

pub fn lit_at(rows : &[Row], t : f64, previous : usize) -> Lit

The lit rows at t. previous is the anchor last time, kept through gaps.

lyrics_view

pub fn lyrics_view(id : impl Into<SharedString>, lyrics : impl Into<Arc<Lyrics>>, clock : PlaybackClock) -> LyricsView

Lyrics following clock. Size it with the style; it fills what it is given.

LyricsView methodDoes
.duration(duration : Option<Duration>)
.resync_after(after : Duration)
.empty_text(text : impl Into<SharedString>)
.on_line_click(f : impl Fn(&LyricClicked, &mut Window, &mut App) + 'static)
.on_follow_change(f : impl Fn(&LyricsFollowChanged, &mut Window, &mut App) + 'static)

media/shelf

shelf

pub fn shelf(id : impl Into<SharedString>, handle : &ShelfHandle) -> Shelf

A sideways-scrolling row of cards. handle keeps its position across renders.

Shelf methodDoes
.arrows(arrows : ShelfArrows)
.free_scrolling()Stops wherever the scroll ends instead of on a card's edge.
.label(label : impl Into<SharedString>)
.on_scroll(f : impl Fn(&ShelfScrolled, &mut Window, &mut App) + 'static)

media/transport

seek_bar

pub fn seek_bar(id : impl Into<SharedString>, clock : PlaybackClock) -> SeekBar

A playback scrubber over clock. Give it the track's duration; it fires [Seeked].

SeekBar methodDoes
.duration(duration : Option<Duration>)
.buffered(buffered : Option<Duration>)
.show_times()
.step(step : Duration)
.label(label : impl Into<SharedString>)
.on_seek(f : impl Fn(&Seeked, &mut Window, &mut App) + 'static)

player_bar

pub fn player_bar(id : impl Into<SharedString>, now : NowPlaying) -> PlayerBar
PlayerBar methodDoes
.layout(layout : TransportLayout)
.compact()
.on_command(f : impl Fn(&TransportCommand, &mut Window, &mut App) + 'static)

volume_icon

pub fn volume_icon(volume : f32, muted : bool) -> Icon

The volume icon for a level, as the system's own volume menu picks it.

media/video

video

pub fn video(source : impl Into<SharedString>) -> Video

A video from a path or URL, paused until [Video::playing] is set.

Video methodDoes
.id(id : impl Into<SharedString>)
.playing(playing : bool)
.muted(muted : bool)
.looping(looping : bool)
.cover()Crops the picture to fill the box instead of letterboxing it.
.alt(alt : impl Into<SharedString>)
.on_ready(f : impl Fn(&VideoReady, &mut Window, &mut App) + 'static)
.on_end(f : impl Fn(&VideoEnded, &mut Window, &mut App) + 'static)
.on_error(f : impl Fn(&VideoFailed, &mut Window, &mut App) + 'static)

palette

palette_item

pub fn palette_item(id : impl Into<SharedString>, title : impl Into<SharedString>) -> PaletteItem
PaletteItem methodDoes
.subtitle(subtitle : impl Into<SharedString>)
.icon(icon : Icon)
.icon_bytes(bytes : impl Into<Arc<[u8]>>)
.hint(hint : impl Into<SharedString>)
.completion(completion : impl Into<SharedString>)

command_palette

pub fn command_palette(id : impl Into<SharedString>) -> CommandPalette

A palette over the active window. The element takes no space where it sits; place it anywhere in the window's tree (scaffold().overlay(..) reads best).

CommandPalette methodDoes
.open(open : bool)
.placeholder(placeholder : impl Into<SharedString>)
.query(query : impl Into<SharedString>)The text a present starts from. Feeding back what [PaletteQueryChanged] reported changes nothing on screen.
.items(items : impl IntoIterator<Item = PaletteItem>)The rows, already filtered and ordered.
.on_query_change(f : impl Fn(&PaletteQueryChanged, &mut Window, &mut App) + 'static)
.on_activate(f : impl Fn(&PaletteActivated, &mut Window, &mut App) + 'static)
.on_submit(f : impl Fn(&PaletteSubmitted, &mut Window, &mut App) + 'static)
.on_cancel(f : impl Fn(&PaletteCancelled, &mut Window, &mut App) + 'static)

panes/dock

empty_dock

pub fn empty_dock<T>() -> DockModel<T>

dock_panel_of

pub fn dock_panel_of<T>(tabs : Vec<DockTab<T>>, active_tab_id : Option<&str>) -> DockPanel<T>

A panel over tabs, active tab defaulting to the first. An empty tab list is not a legal panel ([close_tab] collapses the panel instead).

seed_dock

pub fn seed_dock<T>(groups : Vec<Vec<DockTab<T>>>) -> DockModel<T>

Balanced horizontal dock over one panel per tab group, panel ids "1" to "n". Groups with no tabs are dropped, so every leaf starts with at least one tab.

seed_dock_with

pub fn seed_dock_with<T>(groups : Vec<Vec<DockTab<T>>>, id : impl Fn(&DockPanel<T>, usize) -> String) -> DockModel<T>

dock_panels

pub fn dock_panels<T>(m : &DockModel<T>) -> Vec<(&PaneId, &DockPanel<T>)>

Panels in layout order, as (panel id, panel).

find_dock_panel

pub fn find_dock_panel<'a, T>(m : &'a DockModel<T>, panel_id : &str) -> Option<&'a DockPanel<T>>

find_dock_tab

pub fn find_dock_tab<'a, T>(m : &'a DockModel<T>, tab_id : &str) -> Option<DockTabLocation<'a, T>>

active_dock_tab

pub fn active_dock_tab<T>(panel : &DockPanel<T>) -> Option<&DockTab<T>>

add_tab

pub fn add_tab<T : Clone>(m : &DockModel<T>, panel_id : &str, tab : DockTab<T>, index : Option<usize>) -> DockModel<T>

Adds a tab to an existing panel and activates it. A tab id already used anywhere in the dock is rejected (same tree), since every op here addresses tabs by id.

close_tab

pub fn close_tab<T : Clone>(m : &DockModel<T>, tab_id : &str) -> DockModel<T>

Closes a tab; the last tab in a panel closes the panel, which collapses the split and gives the space back to the sibling.

activate_tab

pub fn activate_tab<T : Clone>(m : &DockModel<T>, tab_id : &str) -> DockModel<T>

Selects a tab inside its own panel. Focus is a separate op (focus_pane): activating a tab in a background panel should not steal the focus ring.

move_tab

pub fn move_tab<T : Clone>(m : &DockModel<T>, tab_id : &str, target_panel_id : &str, index : Option<usize>) -> DockModel<T>

Moves a tab to index of target_panel_id. Within one panel this is a reorder and leaves the active tab alone; across panels the tab is activated in its new home, which takes the focus with it, and a source panel left empty collapses.

undock_tab

pub fn undock_tab<T : Clone>(m : &DockModel<T>, tab_id : &str, zone : DockEdgeZone) -> DockModel<T>

Pulls a tab out of its panel into a new panel beside it. A panel holding one tab has nothing to undock, so that is a same-tree no-op.

dock_panel

pub fn dock_panel<T : Clone>(m : &DockModel<T>, panel_id : &str, target_panel_id : &str, zone : DockZone) -> DockModel<T>

Relocates a whole panel against another one. Center merges its tabs into the target's stack; the four edges split the target and take that side. [apply_dock_drop] routes a drop here.

hit_test_dock_zone

pub fn hit_test_dock_zone(rect : DockRect, px : f32, py : f32, edge : Option<f32>) -> DockZone

Which zone a pointer at (px, py) lands in over rect. Pure geometry: the outer edge fraction (default 0.25, clamped to [0.01, 0.5]) of each side is that side's zone, the middle is Center. A point past an edge still names that edge; a degenerate rect is all Center.

dock_drag_payload

pub fn dock_drag_payload(kind : DockDragKind, id : &str) -> String

The drag payload a dock drag source carries. Namespaced because the drop side also receives plain text dragged in from other applications, which must not be read as a tab id.

parse_dock_drag

pub fn parse_dock_drag(payload : &str) -> Option<DockDrag>

The inverse and the guard: anything not minted by [dock_drag_payload] is None, which every drop path treats as "not ours, ignore".

dock_panel_rects

pub fn dock_panel_rects<T>(m : &DockModel<T>, size : DockSize) -> Vec<(PaneId, DockRect)>

Every panel's rect inside a dock of size, in layout order, from the split ratios alone.

dock_zone_at

pub fn dock_zone_at<T>(m : &DockModel<T>, panel_id : &str, x : f32, y : f32, size : Option<DockSize>, edge : Option<f32>) -> DockZone

Zone a drop point over panel_id lands in. x and y are panel-local, so the hit test runs against a rect at the origin. No size, or a panel not in the model, means Center, the one zone that needs no geometry.

apply_dock_drop

pub fn apply_dock_drop<T : Clone>(m : &DockModel<T>, payload : &str, target_panel_id : &str, zone : DockZone) -> DockModel<T>

Turns one drop into one model op, and is the whole drop policy:

A drag that ends where it started returns the same tree.

serialize_dock

pub fn serialize_dock<T : Clone>(m : &DockModel<T>) -> DockSnapshot<T>

deserialize_dock

pub fn deserialize_dock<T>(raw : DockSnapshot<T>, is_data : impl Fn(&T) -> bool) -> DockModel<T>

Rebuilds a dock from persisted data, on migrate_panes terms: anything malformed rejects the whole tree back to [empty_dock]. A panel with no tabs, a tab without an id, tab data failing is_data and a tab id used twice all count as malformed; an active_tab_id naming a tab that is gone is repaired to the panel's first tab instead.

panes/tiles

empty_tiles

pub fn empty_tiles<T>(columns : i32) -> TileModel<T>

seed_tiles

pub fn seed_tiles<T : Clone>(items : Vec<TilePlacement<T>>, columns : i32) -> TileModel<T>

Places items in order, each one dropped at its requested cell and pushed clear of what is already down. Ids default to "1" to "n".

find_tile

pub fn find_tile<'a, T>(m : &'a TileModel<T>, id : &str) -> Option<&'a Rc<Tile<T>>>

place_tile

pub fn place_tile<T : Clone>(m : &TileModel<T>, placement : TilePlacement<T>) -> TileModel<T>

Adds a tile at the cells it asks for, pushing whatever was there down. An id already in the model is rejected (same tree), the way add_tab rejects a duplicate tab id.

remove_tile

pub fn remove_tile<T>(m : &TileModel<T>, id : &str) -> TileModel<T>

move_tile

pub fn move_tile<T : Clone>(m : &TileModel<T>, id : &str, x : i32, y : i32) -> TileModel<T>

resize_tile

pub fn resize_tile<T : Clone>(m : &TileModel<T>, id : &str, w : i32, h : i32) -> TileModel<T>

raise_tile

pub fn raise_tile<T>(m : &TileModel<T>, id : &str) -> TileModel<T>

Moves a tile last in layout order, which is the top of the paint order.

update_tile

pub fn update_tile<T : Clone + PartialEq>(m : &TileModel<T>, id : &str, f : impl FnOnce(&T) -> T) -> TileModel<T>

Replaces a tile's data with f(current). Equal data is a same-tree no-op.

tile_drag_payload

pub fn tile_drag_payload(id : &str) -> String

The drag payload a tile carries, namespaced for the same reason as dock_drag_payload: text dragged in from another application arrives on the same drop handler.

parse_tile_drag

pub fn parse_tile_drag(payload : &str) -> Option<&str>

tile_cell_at

pub fn tile_cell_at<T>(m : &TileModel<T>, size : TileSize, x : f32, y : f32) -> TileCell

Cell under a point in the grid's coordinate space. Cells are taken as uniform, which is what the grid draws when every tile expands. Points outside the grid clamp to its edge cells.

apply_tile_drop

pub fn apply_tile_drop<T : Clone>(m : &TileModel<T>, payload : &str, size : TileSize, x : f32, y : f32) -> TileModel<T>

Turns one drop into one model op: the cell under the pointer becomes the dragged tile's top-left, and [move_tile] pushes whatever it lands on clear. A tile dropped back on the cell it already occupies returns the same tree, as does a payload from anything but a tile.

serialize_tiles

pub fn serialize_tiles<T : Clone>(m : &TileModel<T>) -> TileSnapshot<T>

deserialize_tiles

pub fn deserialize_tiles<T : Clone>(raw : TileSnapshot<T>, columns : i32, is_data : impl Fn(&T) -> bool) -> TileModel<T>

Rebuilds a tile layout from persisted data. An empty or duplicate id, or data failing is_data, rejects the whole layout back to empty_tiles(columns); columns is also the fallback when the persisted column count is absent. Loaded tiles are clamped and pushed clear of each other, so a hand-edited file cannot land an overlapping layout.

panes/views

pane_tree

pub fn pane_tree<T : 'static>(id : impl Into<SharedString>, tree : &PaneTree<T>, leaf : impl Fn(Leaf<'_, T>, bool) -> AnyElement + 'static) -> PaneTreeView<T>

Renders tree; leaf draws each leaf, told whether it is the focused one.

PaneTreeView methodDoes
.on_resize(f : impl Fn(&PaneResized, &mut Window, &mut App) + 'static)A divider moved; the app applies it with set_pane_ratio.

dock_view

pub fn dock_view<T : 'static>(id : impl Into<SharedString>, model : &DockModel<T>, tab : impl Fn(&DockTab<T>) -> AnyElement + 'static) -> DockView<T>

Renders model; tab draws a tab's content. Every tab stays mounted, so a terminal or a page in a background tab keeps running.

DockView methodDoes
.on_activate(f : impl Fn(&TabChanged, &mut Window, &mut App) + 'static)A tab was picked; the app applies it with activate_tab.
.on_close(f : impl Fn(&TabCloseRequested, &mut Window, &mut App) + 'static)A tab's close was pressed; the app applies it with close_tab.
.on_resize(f : impl Fn(&PaneResized, &mut Window, &mut App) + 'static)

tiles_view

pub fn tiles_view<T : 'static>(id : impl Into<SharedString>, model : &TileModel<T>, row_height : Pixels, tile : impl Fn(&Tile<T>) -> AnyElement + 'static) -> TilesView<T>

rich

text_color

pub fn text_color(theme : &Theme, color : TextColor, ink : Option<Hsla>) -> Hsla

The colour color names under theme. ink is the ink of a filled surface the text sits on (a sent bubble): every token but a custom colour resolves to it there, since the surface's own ink is the only colour that reads on it at 4.5:1.

scaffold

scaffold

pub fn scaffold() -> Scaffold
Scaffold methodDoes
.toolbar(toolbar : Toolbar)
.sidebar(sidebar : Pane)
.inspector(inspector : Pane)
.content(content : impl IntoElement)
.overlay(overlay : impl IntoElement)Floats over the content: palettes, sheets drawn in-window.
pub fn sidebar() -> Pane

The sidebar. On macOS its material, width and collapse come from the split view.

Pane methodDoes
.collapsed(collapsed : bool)Controlled: the pane shows or hides when this changes. A collapse the user makes is reported through [Pane::on_collapse_change].
.on_collapse_change(handler : impl Fn(&PaneCollapsed, &mut Window, &mut App) + 'static)
.width(width : Pixels)Width the pane opens at.

inspector

pub fn inspector() -> Pane

The inspector, on the trailing side.

Pane methodDoes
.collapsed(collapsed : bool)Controlled: the pane shows or hides when this changes. A collapse the user makes is reported through [Pane::on_collapse_change].
.on_collapse_change(handler : impl Fn(&PaneCollapsed, &mut Window, &mut App) + 'static)
.width(width : Pixels)Width the pane opens at.

source_list

source_node

pub fn source_node(id : impl Into<SharedString>, title : impl Into<SharedString>) -> SourceNode

A row with id showing title.

SourceNode methodDoes
.parent(parent : impl Into<SharedString>)
.caption(caption : impl Into<SharedString>)
.icon(icon : Icon)
.badge(badge : impl Into<SharedString>)
.has_children(has : bool)
.expanded(expanded : bool)
.selectable(selectable : bool)
.actions(ids : impl IntoIterator<Item = impl Into<SharedString>>)

source_section

pub fn source_section(id : impl Into<SharedString>, title : impl Into<SharedString>) -> SourceNode

A section header; rows name it as their parent. Expanded unless the app collapses it.

SourceNode methodDoes
.parent(parent : impl Into<SharedString>)
.caption(caption : impl Into<SharedString>)
.icon(icon : Icon)
.badge(badge : impl Into<SharedString>)
.has_children(has : bool)
.expanded(expanded : bool)
.selectable(selectable : bool)
.actions(ids : impl IntoIterator<Item = impl Into<SharedString>>)

source_action

pub fn source_action(id : impl Into<SharedString>, icon : Icon) -> SourceAction
SourceAction methodDoes
.label(label : impl Into<SharedString>)
.tooltip(tooltip : impl Into<SharedString>)
.destructive()

source_tree

pub fn source_tree(id : impl Into<SharedString>) -> SourceTree
SourceTree methodDoes
.nodes(nodes : impl IntoIterator<Item = SourceNode>)
.actions(actions : impl IntoIterator<Item = SourceAction>)The action catalog rows reference by id.
.selected(id : impl Into<SharedString>)
.selected_opt(id : Option<SharedString>)
.action_visibility(visibility : ActionVisibility)
.empty_state(icon : Option<Icon>, title : impl Into<SharedString>, description : Option<SharedString>)
.section(title : impl Into<SharedString>, items : impl IntoIterator<Item = SourceItem>)A titled group of rows; nested items are expanded.
.items(items : impl IntoIterator<Item = SourceItem>)Rows with no group row above them; nested items are expanded.
.on_select(f : impl Fn(&SourceSelected, &mut Window, &mut App) + 'static)
.on_activate(f : impl Fn(&SourceActivated, &mut Window, &mut App) + 'static)
.on_expand(f : impl Fn(&SourceExpanded, &mut Window, &mut App) + 'static)
.on_collapse(f : impl Fn(&SourceCollapsed, &mut Window, &mut App) + 'static)
.on_action(f : impl Fn(&SourceActionClicked, &mut Window, &mut App) + 'static)

source_item

pub fn source_item(id : impl Into<SharedString>, title : impl Into<SharedString>) -> SourceItem

One row: an id the app selects by, a title, and optionally an icon, a badge and children.

SourceItem methodDoes
.icon(icon : Icon)
.badge(badge : impl Into<SharedString>)
.children(children : impl IntoIterator<Item = SourceItem>)

source_list

pub fn source_list(id : impl Into<SharedString>) -> SourceTree

A sidebar of fixed places in titled sections: [SourceTree::section] and [SourceTree::items] fill it.

SourceTree methodDoes
.nodes(nodes : impl IntoIterator<Item = SourceNode>)
.actions(actions : impl IntoIterator<Item = SourceAction>)The action catalog rows reference by id.
.selected(id : impl Into<SharedString>)
.selected_opt(id : Option<SharedString>)
.action_visibility(visibility : ActionVisibility)
.empty_state(icon : Option<Icon>, title : impl Into<SharedString>, description : Option<SharedString>)
.section(title : impl Into<SharedString>, items : impl IntoIterator<Item = SourceItem>)A titled group of rows; nested items are expanded.
.items(items : impl IntoIterator<Item = SourceItem>)Rows with no group row above them; nested items are expanded.
.on_select(f : impl Fn(&SourceSelected, &mut Window, &mut App) + 'static)
.on_activate(f : impl Fn(&SourceActivated, &mut Window, &mut App) + 'static)
.on_expand(f : impl Fn(&SourceExpanded, &mut Window, &mut App) + 'static)
.on_collapse(f : impl Fn(&SourceCollapsed, &mut Window, &mut App) + 'static)
.on_action(f : impl Fn(&SourceActionClicked, &mut Window, &mut App) + 'static)

split

split

pub fn split(id : impl Into<SharedString>, axis : Axis) -> Split

A split of two panes along axis. id keys it, so the panes keep their content when a sibling appears or goes.

Split methodDoes
.ratio(ratio : f32)
.label(label : impl Into<SharedString>)
.first(content : impl IntoElement)The leading (or top) pane's content.
.second(content : impl IntoElement)
.first_pane(pane : SplitPane)The leading pane, for one with a minimum or maximum size.
.second_pane(pane : SplitPane)
.on_resize(f : impl Fn(&SplitResized, &mut Window, &mut App) + 'static)

split_pane

pub fn split_pane() -> SplitPane
SplitPane methodDoes
.min_size(min : Pixels)The pane never shrinks below min points along the split's axis.
.max_size(max : Pixels)

status_page

status_page

pub fn status_page(title : impl Into<SharedString>) -> StatusPage

An empty state titled title, centred in the room it is given.

StatusPage methodDoes
.icon(icon : Icon)
.description(description : impl Into<SharedString>)
.compact()
.id(id : impl Into<SharedString>)Keys the header, for automation and for two status pages side by side.

tabs

tab_strip

pub fn tab_strip(id : impl Into<SharedString>) -> TabStrip
TabStrip methodDoes
.tab(id : impl Into<SharedString>, title : impl Into<SharedString>)
.tabs(tabs : impl IntoIterator<Item = TabSpec>)
.selected(id : impl Into<SharedString>)
.presentation(presentation : TabStyle)
.add_button(shown : bool)
.label(label : impl Into<SharedString>)
.on_select(f : impl Fn(&TabChanged, &mut Window, &mut App) + 'static)
.on_close(f : impl Fn(&TabCloseRequested, &mut Window, &mut App) + 'static)
.on_add(f : impl Fn(&TabAddRequested, &mut Window, &mut App) + 'static)

tab_page

pub fn tab_page(id : impl Into<SharedString>, title : impl Into<SharedString>) -> TabPage
TabPage methodDoes
.icon(icon : Icon)
.closable()Shows a close button on the tab (strip style); a press reports [TabCloseRequested].

tab_view

pub fn tab_view(id : impl Into<SharedString>) -> TabView

In-window tabs. id keys the strip, which is what automation finds (setValue with a tab's title or id selects it); each page is keyed by its tab's id.

TabView methodDoes
.tab(page : TabPage)
.tabs(pages : impl IntoIterator<Item = TabPage>)
.selected(id : impl Into<SharedString>)
.presentation(presentation : TabStyle)
.add_button(shown : bool)
.label(label : impl Into<SharedString>)
.homogeneous(homogeneous : bool)Measures as the biggest page and keeps every page mounted (the default), or mounts only the selected page and takes its size.
.disabled(disabled : bool)
.on_select(f : impl Fn(&TabChanged, &mut Window, &mut App) + 'static)
.on_close(f : impl Fn(&TabCloseRequested, &mut Window, &mut App) + 'static)
.on_add(f : impl Fn(&TabAddRequested, &mut Window, &mut App) + 'static)

titlebar

titlebar

pub fn titlebar() -> Titlebar
Titlebar methodDoes
.title(title : impl Into<SharedString>)Replaces the window's title, which the row shows when nothing else sits leading.
.leading(item : impl IntoElement)
.trailing(item : impl IntoElement)
.controls(controls : WindowControls)Places the OS window controls itself (at a point, or in an embedded slot here) instead of where the OS puts them.

toast

toast

pub fn toast(id : impl Into<SharedString>, title : impl Into<SharedString>) -> Toast

A toast with id (echoed in its events) showing title for [DEFAULT_TIMEOUT].

Toast methodDoes
.action(label : impl Into<SharedString>)A button; clicking it fires [ToastActionClicked] and dismisses the toast.
.timeout(timeout : Duration)
.persistent()Stays until dismissed.
.high_priority()

toast_overlay

pub fn toast_overlay(id : impl Into<SharedString>) -> ToastOverlay

The window's toasts. Takes no space where it sits; one per window.

ToastOverlay methodDoes
.toasts(toasts : impl IntoIterator<Item = Toast>)The queue, oldest first.
.on_dismiss(f : impl Fn(&ToastDismissed, &mut Window, &mut App) + 'static)
.on_action(f : impl Fn(&ToastActionClicked, &mut Window, &mut App) + 'static)
pub fn banner(id : impl Into<SharedString>, title : impl Into<SharedString>) -> Banner

A message bar across its container: title and an optional button. Hidden until revealed.

Banner methodDoes
.action(label : impl Into<SharedString>)
.revealed(revealed : bool)
.on_action(f : impl Fn(&BannerActionClicked, &mut Window, &mut App) + 'static)

toolbar

system_item

pub fn system_item(item : SystemItem) -> AnyElement

toolbar_sidebar_toggle

pub fn toolbar_sidebar_toggle() -> AnyElement

The system sidebar toggle.

toolbar

pub fn toolbar() -> Toolbar
Toolbar methodDoes
.item(item : impl IntoElement)
.labeled_item(label : impl Into<SharedString>, item : impl IntoElement)An item with the label the overflow menu and customization show.
.leading(item : impl IntoElement)Sits before the title: window controls embedded in the toolbar, a back button.
.title(title : impl Into<SharedString>)
.display(display : ToolbarDisplay)
.flexible_space()Pushes the items after it to the trailing edge.
.space()
.sidebar_toggle()
.tab(id : impl Into<SharedString>, label : impl Into<SharedString>, icon : crate::icon::Icon)A selectable tab with an icon and a label, as settings windows show. Controlled: the app sets [Toolbar::selected_tab] from [TabSelected].
.selected_tab(id : impl Into<SharedString>)
.on_tab(handler : impl Fn(&TabSelected, &mut Window, &mut App) + 'static)
.inspector_toggle()