plushie/ui

Ergonomic UI builder functions.

Provides convenience functions for building UI trees without importing individual widget modules. Uses an opaque Attr type for widget properties.

Types

An opaque attribute for widget properties.

pub opaque type Attr

Values

pub fn a11y(a: a11y.A11y) -> Attr

Set accessibility properties on the widget.

pub fn align_x(a: alignment.Alignment) -> Attr

Set horizontal alignment of the widget or its content.

pub fn align_y(a: alignment.Alignment) -> Attr

Set vertical alignment of the widget or its content.

pub fn alt(t: String) -> Attr

Set alt text for an image widget (used by screen readers).

pub fn background(c: color.Color) -> Attr

Set the widget background color.

pub fn border(b: border.Border) -> Attr

Set the widget border.

pub fn button(
  id: String,
  label: String,
  attrs: List(Attr),
) -> node.Node

Create a button widget with the given label text.

pub fn button_(id: String, label: String) -> node.Node

Button with no attrs.

pub fn canvas(id: String, attrs: List(Attr)) -> node.Node

Create a canvas widget for custom drawing with shapes and paths.

pub fn checkbox(
  id: String,
  label: String,
  checked: Bool,
  attrs: List(Attr),
) -> node.Node

Create a checkbox widget with the given label and checked state.

pub fn clip(enabled: Bool) -> Attr

Enable or disable content clipping at the widget boundary.

pub fn column(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a vertical column layout widget.

pub fn container(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a container widget that wraps its children with optional padding, alignment, and sizing.

pub fn decorative(d: Bool) -> Attr

Mark an image as decorative (hidden from screen readers).

pub fn description(d: String) -> Attr

Set a description for accessibility purposes.

pub fn disabled(d: Bool) -> Attr

Disable or enable the widget for user interaction.

pub fn event_rate(r: Int) -> Attr

Set the per-widget event rate limit (events per second).

pub fn exists(tree_node: node.Node, id: String) -> Bool

Check whether a node with the given ID exists in the tree.

pub fn exit_on_close(e: Bool) -> Attr

Set whether the application exits when this window is closed.

pub fn find(
  tree_node: node.Node,
  id: String,
) -> option.Option(node.Node)

Search the tree for a node with the given ID. Returns None if not found.

pub fn floating(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a floating widget for content that hovers above other widgets.

pub fn font_size(s: Float) -> Attr

Set the text font size in logical pixels.

pub fn grid(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a grid layout widget.

pub fn height(h: length.Length) -> Attr

Set the widget height.

pub fn image(
  id: String,
  source: String,
  attrs: List(Attr),
) -> node.Node

Create an image widget from a source path or handle.

pub fn keyed_column(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a keyed column layout for efficient child reconciliation.

pub fn label(l: String) -> Attr

Set the label text for a widget.

pub fn markdown(
  id: String,
  content: String,
  attrs: List(Attr),
) -> node.Node

Create a markdown widget that renders the given markdown content.

pub fn max_height(h: Float) -> Attr

Set the maximum height in logical pixels.

pub fn max_width(w: Float) -> Attr

Set the maximum width in logical pixels.

pub fn mouse_area(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a mouse area widget that captures mouse events on its children.

pub fn on_submit(enabled: Bool) -> Attr

Enable or disable the on_submit event for text input widgets.

pub fn overlay(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create an overlay widget for popover-style content.

pub fn padding(p: padding.Padding) -> Attr

Set padding around the widget content.

pub fn pane_grid(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a pane grid layout with resizable, splittable panes.

pub fn pin(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a pin widget for positioning a child at an absolute offset.

pub fn placeholder(p: String) -> Attr

Set the placeholder text shown when the input is empty.

pub fn progress_bar(
  id: String,
  range: #(Float, Float),
  val: Float,
  attrs: List(Attr),
) -> node.Node

Create a progress bar with the given min/max range and current value.

pub fn responsive(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a responsive layout widget that adapts to available space.

pub fn row(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a horizontal row layout widget.

pub fn rule(id: String, attrs: List(Attr)) -> node.Node

Horizontal or vertical rule (divider).

pub fn scrollable(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a scrollable container widget.

pub fn secure(s: Bool) -> Attr

Enable secure (password) mode for text input, hiding characters.

pub fn sensor(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a sensor widget that reports its size and position changes.

pub fn shadow(s: shadow.Shadow) -> Attr

Set the widget drop shadow.

pub fn slider(
  id: String,
  range: #(Float, Float),
  val: Float,
  attrs: List(Attr),
) -> node.Node

Create a slider widget with the given min/max range and current value.

pub fn space(id: String, attrs: List(Attr)) -> node.Node

Flexible space widget.

pub fn spacing(s: Int) -> Attr

Set spacing between child widgets in pixels.

pub fn stack(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a stack widget that layers children on top of each other.

pub fn style(s: String) -> Attr

Set the widget style class name.

pub fn table(id: String, attrs: List(Attr)) -> node.Node

Create a data table widget.

pub fn text(
  id: String,
  content: String,
  attrs: List(Attr),
) -> node.Node

Create a text widget displaying the given content string.

pub fn text_(id: String, content: String) -> node.Node

Text with no attrs.

pub fn text_color(c: color.Color) -> Attr

Set the text color.

pub fn text_input(
  id: String,
  val: String,
  attrs: List(Attr),
) -> node.Node

Create a single-line text input widget with the given value.

pub fn themer(
  id: String,
  theme: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a themer widget that applies a local theme to its children.

pub fn title(t: String) -> Attr

Set the window title.

pub fn tooltip(
  id: String,
  tip: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a tooltip widget that shows tip text when hovering its children.

pub fn value(v: String) -> Attr

Set the current value of an input widget.

pub fn width(w: length.Length) -> Attr

Set the widget width.

pub fn window(
  id: String,
  attrs: List(Attr),
  children: List(node.Node),
) -> node.Node

Create a window node. Only detected at the root or as a direct child of the root node.

pub fn window_size(w: Float, h: Float) -> Attr

Set the initial window size in logical pixels.

Search Document