1# GPUI Examples
2
3Examples can be run from the Zed repository root:
4
5```sh
6cargo run -p gpui --example hello_world
7```
8
9## Where to start
10
11- `hello_world` shows the basic shape of a GPUI application: create an
12 `Application`, open a window, create a root view, and render a `div`.
13- `input` demonstrates text input, focus, selections, clipboard actions, and
14 keyboard bindings.
15- `uniform_list` shows how to render a simple virtualized list.
16- `testing` demonstrates `#[gpui::test]`, `TestAppContext`, actions, focus, and
17 window-based tests.
18
19## Layout and styling
20
21- `grid_layout` demonstrates CSS-grid-style layout.
22- `opacity` demonstrates opacity styling.
23- `pattern` shows patterned backgrounds.
24- `shadow` demonstrates box shadows.
25- `text` shows styled text rendering.
26- `text_layout` demonstrates text alignment, decoration, weights, and wrapping.
27- `text_wrapper` shows wrapping text content.
28
29## Interaction
30
31- `anchor` demonstrates anchored positioning.
32- `data_table` combines virtualized list rendering with table-style rows and a
33 custom scrollbar.
34- `drag_drop` shows draggable elements and drop targets.
35- `focus_visible` demonstrates keyboard-visible focus styling.
36- `mouse_pressure` demonstrates pressure-sensitive pointer input where supported.
37- `popover` shows floating layers with `deferred` and `anchored`.
38- `scrollable` demonstrates scrollable content.
39- `tab_stop` shows keyboard tab navigation.
40
41## Images, drawing, and animation
42
43- `animation` demonstrates GPUI animations and animated SVG transforms.
44- `gif_viewer` shows GIF rendering.
45- `gradient` demonstrates linear gradients and color spaces.
46- `image` shows local and remote image loading, image sizing, and asset setup.
47- `image_gallery` demonstrates image caching and loading remote images.
48- `image_loading` shows image loading states and asset loading.
49- `painting` demonstrates custom drawing with paths and canvas.
50- `svg` shows SVG rendering.
51
52## Windows and application behavior
53
54- `move_entity_between_windows` shows moving an entity between windows.
55- `on_window_close_quit` demonstrates quitting when a window closes.
56- `set_menus` shows application menu setup.
57- `window` demonstrates creating normal, dialog, popup, and floating windows.
58- `window_positioning` demonstrates window bounds and placement.
59- `window_shadow` demonstrates window shadow styling.
60
61## Specialized examples
62
63These examples are useful when working on GPUI itself, but they may not be the
64best starting point for new applications:
65
66- `active_state_bug` is a focused active-state reproduction.
67- `layer_shell` demonstrates Linux layer-shell windows.
68- `list_example` demonstrates bottom-aligned list state and scrollbar behavior.
69- `ownership_post` supports the ownership and data-flow documentation.
70- `paths_bench` is a path rendering benchmark.
71- `tree` renders a deep tree of nested elements.