Expand description
§Tutorial: build a todo list
Build a keyboard-friendly todo list from an empty Rust project. You will first create a window, then add state, layout, text input, reusable components and filtering. The later chapters add background work for undo, animation and accessibility, and finally headless tests. Each chapter leaves the previous program runnable so you can check the new behavior before continuing.
The finished app is the todos example. Run it with cargo run --example todos
in a checkout of the GPUI repository.
Follow the chapters in order because each one extends the program from the previous chapter:
- Hello, window: an application, a window and your first view.
- State and events: data that changes when you click, and telling GPUI to redraw.
- Layout and style: flexbox, spacing, color and hover states.
- Text input: a text field, focus, actions and key bindings.
- Components: reusable pieces and list filtering.
- Background work: undoing a delete with a task that expires.
- Polish: animation and accessibility.
- Testing: driving the app from a headless test, including input and asynchronous work.
§Before you start
You should be comfortable with Rust structs, closures, traits and iterators. No experience with another UI framework is required.
You need a recent stable Rust toolchain and, on Linux, a few system packages. Start a project lists them for each platform.
Compare your code with the finished todos example if you get stuck or want to skip ahead. Follow the links at each chapter’s end when you need to adapt that step beyond the todo list or want the GPUI concept behind the mechanism it introduced.
Modules§
- ch1_
hello_ window - 1. Hello, window
- ch2_
state - 2. State and events
- ch3_
layout_ and_ style - 3. Layout and style
- ch4_
text_ input - 4. Text input
- ch5_
components - 5. Components
- ch6_
background_ work - 6. Background work
- ch7_
polish - 7. Polish
- ch8_
testing - 8. Testing