Kryon Examples
This directory contains .kry example programs demonstrating Kryon library
components. The C files used for native and web builds are generated into
../build/examples/codegen and are not source files.
Available Examples
- 01_file_dialog - File dialog component with theme integration
- 02_buttons - Button styles and click handling
- 03_theme - Theme switching
- 04_modal - Modal dialogs
- 05_color - Color helpers
- 06_scaling - UI scaling
- 07_layout - Existing layout helpers
- 09_geometry - Packed frames, grid cells, placement, separators
- 10_menus - Menubar and menu items
- 11_basic_controls - Radio, progress, spinbox, combobox, label frame
- 12_collections - Listbox, tree view, table view
- 13_text_editor - Text area plus clipboard helpers
- 14_canvas - Canvas clipping, grid, and hit testing
- 15_containers - Notebook, paned view, collapsible section
- 16_dialogs - Message, confirm, prompt, and color picker
- 17_keyboard_platform - Accelerators and clipboard
- 18_accessibility - Accessibility/debug node overlay
- 25_text_area_slider - Editable multiline text with a live background-color slider
- 26_widget_catalog - Native
.krywidget catalog with ten clickable sidebar categories, scrollable previews, editable controls, and click feedback
Requirements
- Kryon library must be built (
makein parent directory) - Edit the
.kryfiles; generated C/H in../build/examples/codegenis disposable - X11 libraries (Linux):
-lGL -lm -lpthread -ldl -lrt -lX11
Building Examples
# Build all examples
make
# Build specific example
make ../build/examples/bin/01_file_dialog
# Clean examples
make clean
Each build transpiles NN_name.kry with k2c, writes generated C/H under
../build/examples/codegen, then compiles the standalone example binary under
../build/examples/bin.
Running Examples
# Interactive menu to select and run examples
make run
# Run directly (after building)
../build/examples/bin/01_file_dialog
IDE Preview
Open this directory in Krait (the standalone Kryon IDE, a separate
kryonlabs/krait repo):
krait .
Krait automatically discovers .kry screens, builds the generated app host under
build/kryon, and reloads when .kry sources change. A project.kryon file is
only needed for full projects that want custom build or run targets.
Example Features
Toolkit Examples
The toolkit examples use one direct API shape per widget: fill the struct that
describes the widget state and call its widget function, such as Button,
TextField, or TableView. Geometry
uses BeginFrameBox, FramePack, GridCell, and Place; canvas uses
BeginCanvas / EndCanvas.
Usage
- Press L to open load file dialog
- Press S to open save file dialog
- Press ESC to exit
- Toggle "Show hidden files" checkbox in dialogs
Widget catalog
The catalog UI lives entirely in 26_widget_catalog.kry and uses standard Kryon
widgets. Build and launch it from the repository root:
make -C examples 26_widget_catalog
./build/examples/bin/26_widget_catalog
Choose a category in the left sidebar. The right pane scrolls independently and
resets to the top when categories change. Numeric controls expose live values;
buttons increment the sidebar click counter. Tabs can be added and closed,
themes apply immediately, and the canvas supports wheel zoom and drag panning. Image samples use the checked-in
icons/tiles.png asset. Escape is reserved for controls; close the window to quit.
See the native catalog audit for verified behavior, visual checks, regression tests, and reproducible audit commands. This example is a native C-target showcase; its Go/JS rendering is not claimed to have equivalent coverage.