Skip to content
DEEIX-AIPublic

About

Native desktop apps in Rust, rendered on the CPU.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

548 stars

Watchers

0 watching

Forks

CPUI

CPUI

Native desktop apps in Rust, rendered on the CPU.

Website · Documentation · Components · 简体中文

CI License Rust 1.89+

CPUI is a native UI framework for Rust desktop applications. It renders entirely on the CPU, requires no GPU, and an 800×600 window uses only 27 MB of memory.

The widget gallery in the light theme The widget gallery in the dark theme

CPUI 0.1 is the first release series. Support for each platform is listed under Platforms.

Features

  • Native. Applications compile to machine code, with no browser or script runtime. Windows, input methods, the clipboard, file dialogs and accessibility use the operating system's own interfaces.
  • Lightweight. An idle 800×600 window uses 27 MB of memory. The hello example builds to a 2 MB executable and opens its window within 100 ms on macOS.
  • Fast. An idle window draws nothing, and a change redraws only the affected region. A full 800×600 frame takes about 0.1 ms; scrolling a 100,000-row list takes about 0.2 ms per frame. See Performance.
  • Immediate mode. The interface is a function of the application's state. Widgets return their results where they are called, so if ui.button("Save").clicked() is a complete click handler, and application data never needs to be synchronized with the interface.
  • Chained styling. Layout and appearance are set with chained methods such as .p(24).gap(12). A theme is a set of named colors and sizes, with light and dark variants and five gray scales.
  • 40+ UI widgets, including sortable tables with multiple selection, trees, virtual lists, searchable selects, date and color pickers, dialogs, sheets, menus and toasts.

Quick start

[dependencies]
cpui = "0.1.3"
use cpui::{App, Options, Ui};

#[derive(Default)]
struct Counter {
    count: u32,
    name: String,
}

impl App for Counter {
    fn ui(&mut self, ui: &mut Ui<'_>) {
        ui.column().p(24).gap(12).children(|ui| {
            ui.heading(format_args!("Clicked {} times", self.count));
            if ui.button("Click").primary().clicked() {
                self.count += 1;
            }
            ui.text_input(&mut self.name).placeholder("Name");
            ui.progress((f64::from(self.count) / 10.0).min(1.0)).w(200);
        });
    }
}

fn main() -> Result<(), cpui::Error> {
    cpui::run(Options::default(), Counter::default())
}

Getting started builds a first application step by step.

Widgets

Group Widgets
Text and display Text, Icon, Image, Avatar, Badge, Alert, Kbd, Skeleton, Spinner, Progress, Empty
Inputs and controls Button, Toggle, Toggle Group, Checkbox, Radio, Switch, Slider, Range Slider, Color Picker, Number Input, Text Input, Textarea, Select, Combobox, Date Picker, Calendar, Tabs, Sidebar Item, Collapsible, Accordion
Forms Field, Form
Data List, Table, Tree
Popups and menus Popover, Dialog, Sheet, Drawer, Alert Dialog, Dropdown Menu, Context Menu, Menu Bar, Toast, Tooltip
Layout Row, Column, Flow, Grid, Stack, Available Width, Container, Card, Resizable, Scroll, Overlay, Separator, Spacer
Custom drawing Canvas, Custom

Each widget is shown live, with its code and options, at cpui.io/components. On the desktop, run the catalog example.

The built-in icons are browsable at cpui.io/icons. They are also published on their own as cpui-icons, a crate with no dependencies that provides each icon as geometry or SVG for use with any renderer.

Documentation

The full documentation is published at cpui.io.

Guides:

Project:

Examples

cargo run --release -p cpui --example hello    # text, buttons, a checkbox and an input
cargo run --release -p cpui --example gallery  # every widget, adapting to the width
cargo run --release -p cpui --example catalog  # the widget catalog, one widget per row
cargo run --release -p cpui --example list     # a virtual list of 100,000 rows
cargo run --release -p cpui --example canvas   # canvas animation
cargo run --release -p cpui --example icons    # every built-in icon, searchable
cargo run --release -p cpui --example theme    # appearance, accent, font size, radius, density
cargo run --release -p cpui --example windows  # several windows sharing one application

Platforms

Platform Minimum Status
macOS 13 Verified
Windows 10 Verified
Linux glibc 2.28 Verified
iOS 16 Experimental; verified in the simulator
Android 8 (API 26) Experimental; verified in the emulator

See the roadmap for details.

Contributing

Contributions are welcome. CONTRIBUTING.md covers the development setup, required checks and conventions. All participants are expected to follow the code of conduct. Security issues are reported as described in SECURITY.md.

Acknowledgements

CPUI would not have been possible without these projects:

Friends

License

Licensed under the Apache License 2.0. The renderer was split out from Winc; see NOTICE.

About

Native desktop apps in Rust, rendered on the CPU.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

548 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages