Expand description
taut: a GUI library for Windows and Linux with no dependencies. It draws its own UI with what the system has: no other crates, no web view, no GPU needed.
An app describes its window in one function, from its own state. The function reruns when something happens; the library lays out the result, diffs it against the screen, and redraws only what changed. Nothing runs while nothing happens.
use taut::Window;
fn main() {
let mut presses = 0;
let window = Window { title: "Hello", width: 320.0, height: 160.0, ..Default::default() };
taut::run(window, move |ui| {
ui.column().pad(16.0).gap(10.0).open();
ui.label(&format!("Pressed {presses} times"));
presses += ui.button("Press").clicked as u32;
ui.close();
});
}§Where to go next
guide: every call on one page, in the order an app needs them.Ui: describes a window. Its calls make boxes (containers:Ui::row,Ui::column,Ui::grid) and parts (widgets:Ui::button,Ui::text_box,Ui::table).Surface: the UI drawn into a pixel buffer, for the app’s own renderer (as a texture) or a DLL;testing::Trial: a window tested with no screen.- The book, a ten-chapter tutorial from a first window to taut inside other programs, is the
package’s
docsfolder (docs/README.md);examples/holds whole apps.
§Features
A program carries only the code it calls. What can’t be told from the calls is a feature,
all off by default: right-to-left (Hebrew, Arabic and other RTL scripts), brahmic (South
and Southeast Asian scripts), emoji (colour emoji), fallback-fonts (characters a font
lacks, in the font Windows would choose), touch (touch, pen and touchpad pinch gestures),
cff (.otf fonts with PostScript outlines), woff2 (WOFF2 web fonts),
color-profiles (image colour profiles), gpu (windows shown by the GPU, see
Renderer), gpu-draw (windows drawn by the GPU too, see Renderer), hdr
(brightness past SDR white on HDR screens, see El::brightness), translations
(built-in words in six more languages) and video (video and sound by the system’s
player, see Video).
§Systems
Windows, Linux under X11 or Wayland, macOS, iOS, Android (through NativeActivity, see
platform::run), and browsers built for wasm32-unknown-unknown (see web); tested on
Windows 11, Ubuntu 26.04, Arch Linux, macOS 26, the iOS 26 simulator and an Android 15
emulator.
Rust 1.88 or newer.
§Terms
A part is a widget, a box a container, a unit a logical pixel (a DIP), and the scale the display scaling factor. What a part tells is its accessibility information; a note is secondary text. The guide’s first section lists the rest.
Re-exports§
pub use canvas::Canvas;pub use color::Color;pub use emoji::Emoji;pub use event::Button;pub use event::Cursor;pub use event::Event;pub use event::Key;pub use event::Mods;pub use font_file::AppFonts;pub use font_file::FontFile;pub use geom::Corners;pub use geom::Insets;pub use geom::Point;pub use geom::Rect;pub use geom::Size;pub use geom::Transform;pub use layout::Align;pub use layout::Flow;pub use layout::Length;pub use path::Path;pub use pen::Cap;pub use pen::Join;pub use pen::Paint;pub use pen::Pen;pub use platform::Clipboard;pub use platform::LocalClipboard;pub use platform::Renderer;pub use platform::Waker;pub use platform::Window;pub use platform::WindowPlacement;pub use platform::run;pub use surface::Surface;pub use surface::Upload;pub use svg::Drawing;pub use text::Face;pub use text::Font;pub use text::TextSystem;pub use theme::ContrastColors;pub use theme::Theme;pub use ui::Icon;pub use ui::Picture;pub use ui::Response;pub use ui::Ui;
Modules§
- bmp
- BMP and ICO decoding, and ICO encoding: Windows’ long-standing image formats, shown without another library, and app-made icons for programs and shortcuts.
- canvas
- The software rasterizer: a pixel buffer and the few primitives a UI is made of. Rectangles (square or rounded, filled or outlined), paths, and glyph coverage from the text system. All anti-aliased, on the CPU.
- color
- Colours: RGB and alpha.
- emoji
- Colour emoji in any text.
- event
- Input events, the same on every system.
- font_
file - Font files: reading TrueType and OpenType fonts, and drawing text with them. For apps shipping their own fonts or icon fonts, looking the same on every system and any pixel buffer.
- geom
- Points, sizes, rectangles and transforms, in units: one unit is one pixel at 100% scale.
- gif
- GIF decoding: still images, and animations as frames (see
animation) with their delays. - guide
- taut on one page
- jpeg
- JPEG decoding and encoding. Decodes what cameras, phones and editors write, and the rarer kinds scanners and medical systems keep: baseline or progressive, 8 or 12 bits, Huffman or arithmetic coded, or lossless at up to 16 bits; greyscale, colour or CMYK, rotated upright per a camera’s EXIF orientation, and converted to screen colours per an embedded ICC profile. Shows a photo with no other library. Not hierarchical JPEG, nor lossless with arithmetic coding: nothing writes them.
- layer_
d3d9 Windows - The UI over a program’s own Direct3D 9 rendering (Direct3D 9Ex too): made once from its device, then drawn each frame with one call, inside the program’s scene.
- layer_
d3d11 Windows - The UI over a program’s own Direct3D 11 rendering: created once from its device and context, then drawn each frame with one call, after the program’s own drawing.
- layer_
d3d12 Windows - The UI over a program’s own Direct3D 12 rendering: made once from its device and the queue it draws with, then drawn each frame with one call, in the program’s command list.
- layer_
opengl - The UI over a program’s own OpenGL rendering (3.3 or newer, core or compatibility profile): created once in its context, then drawn each frame with one call, after the program’s own drawing.
- layer_
vulkan - The UI over a program’s own Vulkan rendering: made once from its device and queue, then drawn each frame with one call, in the program’s command buffer, inside its render pass.
- layout
- Layout. A UI is a tree of boxes: each lays out its children in a row, a column, a grid, or a stack, and each child sizes itself to fit its content, at a fixed size, or as a share of the leftover room.
- path
- Shapes of lines and curves: icons, charts, anything an app draws itself. A shape can be
written as SVG path data (
"M8 3.5v9M3.5 8h9"), so web icons work as they are. - pen
- How shapes are drawn: the pen for strokes (width, caps, joins, dashes), and the ink a fill or stroke uses (one colour, or a gradient across it).
- platform
- What differs per system: opening a window, input, drawing text, the clipboard. Everything else is the same code everywhere.
- png
- PNG reading and writing. Reading takes any PNG a program is likely to ship (every colour type and depth, interlaced too), so an app can show pictures without another library. Writing favours speed over size: a window screenshot comes to a few dozen kilobytes.
- storage
- Where an app keeps its files between runs (settings, window and table layout; see the guide’s “Saving settings between runs”), and writing a file so it is never left half written.
- surface
- The interface drawn into a block of pixels in memory, for whatever shows it: a renderer (as a texture for Direct3D, OpenGL, Vulkan, Metal, a web canvas), a system with no window here yet, or a test that compares pixels.
- svg
- SVG files, read and drawn: icons and logos from drawing programs and icon sets, in their own colours, sharp at any size. No other library needed.
- system_
fonts - System fonts: any by name, the family list for a font picker, and fallback fonts for characters a face’s font lacks.
- testing
- A headless window for an app’s own tests. The interface is clicked, typed into, dragged, scrolled and left to wait, as a user would; elements are found as a screen reader finds them, by role and name; and the rendering is compared with a saved picture.
- text
- Text: measuring, line breaking, and drawing.
- theme
- The colours and sizes an interface is drawn with: dark and light sets, and a pair for high
contrast that Windows’ own contrast colours can replace. Any can be built around one colour
(
accented), made tighter or looser (dense,roomy), or given larger text (text_scaled);followingmakes the one that follows all the person asked their system for. An app can change any part, or bring its own. - ui
- The interface, as an app describes it.
- web
- taut in a browser: the same app, built for
wasm32-unknown-unknown, in a page’s<canvas>. No crates, no bundler: the page loads the program with the loader below. - webp
- WebP reading: lossless and lossy pictures, each with or without alpha, so an app can show web pictures without another library.
Macros§
- inspect
- Implements
Inspectfor a plain app struct, from each field’s options; or for a fieldless enum, from each variant’s name.
Structs§
- Access
Node - One element of the window, as told to a screen reader.
- Animation
- An animation the UI keeps, to show wherever asked.
- Bidi
Text - A text system wrapping another, which draws all left-to-right text, that shows text in
display order. A line without right-to-left letters (judged by its bytes) passes straight
through. Any other is reordered by the bidi algorithm (see
Order) and split into pieces: left-to-right text still goes to the inner system; Hebrew and Arabic letters, and what lies between them, are shaped (shaping.rs) and drawn here, from the inner system’s font for them (an app font) or else the system’s. AUiwraps its text system in one of these itself. - Calendar
Words - Calendar and clock words: English until the app sets its own in
ui.calendar_words, but for month and day names and AM/PM, which are the system’s whileui.localeisNone(CalendarWords::of_the_system). (Date and time formats and the week’s first day: seeui.locale.) - Camera
- Where a scene is seen from, and how.
- Chart
- A chart: series, and how they map onto the axes.
- Chart
View - A chart’s user state, kept by the app (as a
Tableis): zoom and pan, and which series (or pie slices) the user hid through the legend. Shown withui.chart_view. - Code
Editor - A code editor’s state (
Ui::code_editor): the text and the editing state. Kept by the app, one per editor, as aTableis. - Column
- One column of a table, as the app specifies it.
- Date
- A calendar day.
- Dock
- A dock’s layout, kept by the app.
- Edited
Cell - A cell the user edited in place: its row (as
rowscounts them), column (index among the app’s columns), and new value. - El
- A box being built. Each method sets one property.
- Field
- A field’s options: its name and how its editor behaves. A plain name (
"Power") is a field with defaults. - Fields
- The rows of an inspected value, as it lists them: what
Inspect::fieldsgets. - File
Dialog - A file dialog as the app keeps it: one per app, shown when
pick,pick_many,saveorpick_folderasks. - File
Dialog Request - A request for the system’s file dialog, for the window’s host, which asks the system.
- File
Words - The file dialog’s words: English (with the feature
translations, the user’s language) until the app sets its own infiles.words. - Font
Axis - One axis of a variable font: its tag (
b"wght"for weight), and its minimum, default and maximum in its own units (weight is 100 to 900). - Frame
- A frame: a titled box under the nodes. Moved by its title, it carries the nodes whose middle lies inside, and the bends.
- Frame
Words - The labels the app frame uses on icon-only buttons, for screen readers and tooltips. English until the app sets its own.
- Graph
- A node graph the user wires up, as the app keeps it: nodes, wires, and its pan and zoom.
- Graph
Words - The words screen readers hear for a graph’s ports and wires.
- Inspector
- An inspector’s state between runs, kept by the app: divider position, search text, expanded headings, initial values, and the undo history.
- Inspector
Row - Where an inspector row’s editor is described: the UI, and the field’s options.
- Language
- The language of a piece of text, so a font gives its letters the forms of that language.
Serbian and Macedonian write some Cyrillic letters differently from Russian; Romanian puts a
comma, not a cedilla, under s and t; Turkish keeps the dot of an i after an f; Dutch writes
ij as one letter; and CJK fonts have a form of many characters per language. Named in BCP
47:
Language::named("sr"),Language::named("zh-Hant-HK"). - Locale
- Date, time and number formats.
Locale::of_the_system()is the user’s;Locale::PLAINthe library’s: 2026-11-30, 14:05, 1234.5, weeks from Monday. - Markdown
- A Markdown document, parsed once and kept by the app, to show with
Ui::markdown. (What it supports: see the top of this file, or the guide.) - Mesh
- A mesh the interface keeps for scenes: points, and triangles between them.
- Mesh
Instance - A mesh as a scene shows it: where, and in which colours.
- Node
- One node: a box with a title, inputs down its left, outputs down its right, and the app’s content under them.
- Notification
- A system notification the program showed; tells which one was clicked.
- PanZoom
- A pan-and-zoom view: what an app keeps of one. As text, three numbers (
to_string(), and back withparse()). - Panel
- A panel as the app keeps it.
- Paper
- Pages to save as PDF (
pdf) or print (taut::print): each its own size, with shapes, text, pictures and links. Marks go on the page begun last. - Port
- A node’s input or output.
- Preferences
- What the person asked their system for about how windows look and move. The window code
reads it; an app that runs the interface itself (in a DLL, under its own renderer) hands it
over with
ui.set_preferences. - Print
Job - Printing that was asked for, and what came of it once known.
- Recent
Colors - The colours picked last in a window’s colour pickers, newest first (at most 8): one line of
text to keep between runs,
to_string()(“#ff8800 #33aaff80”), back withparse(). - Relaunch
- A later start, as the first copy gets it: its arguments and working folder.
- Reroute
- A bend in a wire: the wire runs through it.
- Screen
- One of the person’s screens, as the system has it.
- Scroll
State - How far a scroll box is scrolled (
Ui::scroll_state). - Second
Window - A second window, as the app keeps it.
- Selection
- Which rows of a list are selected. The app keeps one per list.
- Series
- One series of a chart. A NaN value leaves a gap.
- Span
- A piece of a rich text paragraph (
Ui::rich): text in its own style, or an icon or small picture inline. Anything unset follows the theme: its font and text colour. - String
Syntax - A string syntax of a language.
- Stylus
- A pen (stylus) near the screen, beyond what the mouse it also is reports. For drawing apps: stroke width and opacity, and erasing.
- Syntax
- A language’s syntax for highlighting, and what indents the next line: plain data, so an app writes rules for its own language the same way.
- Table
- What the user did to a table, kept by the app: one per table.
- Text
Edit State - A text box’s cursor, selection and undo state (
Ui::text_edit_state). - Time
- A time of day.
- Touch
- One finger on the screen, as the system reports it.
- Tree
Item - A tree item as the app supplies it.
- Tree
View - A tree the user expands, collapses and selects in, kept by the app (one per tree) beside its own items: which are visible, which selected, and where focus is going.
- Video
video - A video or sound file played by the system’s player, with its newest frame. Opens paused,
at full volume. Dropping it stops it;
Ui::drop_videoalso frees its last frame. - Widget
Words - Words these parts show or tell screen readers, and the names of a range’s thumbs. English
until the app sets its own (
ui.widget_words). - Window
Opening - How a second window should open, for the window code.
- Wire
- A wire from one node’s output into another’s input: each end as node index and port index among its outputs or inputs.
- Zoom
- What two fingers, a touchpad pinch or Ctrl+wheel did to a zooming box since the last run.
Enums§
- Cell
Editor - How a column’s cells are edited in place, if at all.
- Cell
Value - A cell’s new value.
- Date
Order - The order of a date’s day, month and year.
- Dock
Node - One node of a dock’s layout.
- Drag
Data - What a thing dragged out of the window is to the program it is dropped in.
- Drop
Effect - What became of a thing dragged out: another program took it.
- Graph
Action - What the user did to a graph in one run. (Selecting, moving and wiring are already applied: this reports them, for the app to react.)
- HitTest
- What the pointer is over in its window at a point: a hit test.
- Print
Outcome - What came of printing.
- Role
- A box’s role, for a screen reader to announce and to know what can be done with it.
- Severity
- A banner’s severity: its colour and icon.
- Text
Command - An edit command for a text box from an app’s own menu (
Ui::text_command): what the box’s keys and context menu do. - Token
Kind - A code token’s kind, for its colour.
- Touch
Phase - A finger event phase.
- Video
Error video - Why a video did not open.
- Video
Source video - Where a video comes from: a file, an address (
https://,file://), or the file’s bytes. Text with://in it is an address, any other a path. - Window
Kind - A second window’s relation to the first, its owner.
Traits§
- Inspect
- Something an inspector shows: a single-row value with an editor beside its name (a number, text, a colour), or a heading that expands to rows of its own (an app struct, a list, a map).
- Number
- The number types a
numberbox or adragcan hold: every Rust number type.
Functions§
- open_
with_ system - Opens a file, folder or link (
https://...,mailto:...) with the program the system opens it with, as a double click in the file manager does. A relative path is taken from the working folder. It runs on a thread of its own and reports nothing: a file with no program is handled as the system handles it. - Prints the pages of
paper: shows the system’s print dialog (printer, pages, copies) and sends the pages there, listed astitlein the printer’s queue. Returns at once;PrintJob::outcomesays what came of it. On Windows the dialog shows over the window in use once the thread’s messages are taken: at once under a taut window, else from the program’s own message loop. - print_
laid - Prints pages laid out for the paper the person picks: shows the dialog as
print()does, then callslaywith the sheet’s size in units (A4 or Letter, upright or across, or any other) and prints the pages it gives. (Before the dialog, it is called once for A4, to count the pages the dialog offers.) - single_
instance - Makes this the one running copy of program
name(the same in every copy: “org.example.Notes”).truefor the first copy, which from now on gets every later start (Ui::relaunches) and comes forward for it.falsefor a later one, which has just handed its start to the first and should exit. Call once, beforetaut::run, on the window thread. If the first copy cannot be reached within five seconds, or the system has no way, every start is a first.
Type Aliases§
- Id
- A box’s id from one run to the next: a hash of its place in the window’s description, or of
its
.key(..).