Duolith docs

examples

Start with gallery/: one app with a live demo of every feature, in eight areas. FEATURES.md lists every feature with the example and page that show it and a screenshot of it, and has the CLI's real output.

  • gallery/: a tab bar app (a rail on wide windows) whose home screen opens eight areas: Language, Styling and themes, Data, Navigation, Kit core, Overlays, Inputs and media, Navigation parts. Each area is a screen of small demos you can use. It runs with no network (its data is in memory), keeps its images in public/, and has a light/dark switch.
  • minimal/: the smallest app.
  • social/: the showcase feed app from the plan.
  • control-flow/: a todo list with <show>/<otherwise> filters, a keyed list with an index, derived counts, bind:value, a <form> with on:submit, toggles and a long press.
  • components/: a profile and settings screen built from three components (Card, Avatar, SettingRow) with props, a slot and scoped styles.
  • overlays/: every overlay part of the kit (Sheet, Dialog, AlertDialog, Menu, Popover, Tooltip, Toast, Select) in its variants and states, light and dark, with toast() from @duolith/client.
  • kit/: a gallery of the built-in kit, one page per family (buttons, lists and cards, inputs, selection controls, feedback and states), every variant, size and state, light and dark, two columns on a wide window.
  • inputs-and-media/: the kit's pickers (DatePicker, TimePicker, Stepper), search, chips and tabs, and media (Image with its placeholder, fade and fallback, the zoomable ImageViewer, Skeleton), with local images in public/.
  • navigation/: a tab bar layout built with the kit's TabBar and NavHeader (Feed, Search, Profile), post screens at /post/[id] with back, a settings stack inside a nested Profile layout, a guarded /account, a [...topic] help route and a not-found screen.
  • data/: the data layer against a mock server (data/server/server.ts): state that loads, optimistic actions, retries, the offline queue, a live stream, a paged list and form validation.
  • styling/: the utility families and the state, window and scheme prefixes, one page each.
  • theming/: a project theme in theme.yaml, light and dark.
  • rust-module/: a page that calls a Rust module (modules/maths), built to WebAssembly with types, and an about page built on rung 0 (decisions 0075 and 0078). Needs the wasm32-unknown-unknown target and wasm-bindgen-cli 0.2.130.
  • navigation-kit/: a small inbox-and-library app showing every kit navigation part (TabBar with a badge and a rail on wide windows, NavHeader with large titles and automatic back, Toolbar, Breadcrumbs, Link), light and dark.
  • motion/: automatic motion for lists and shows, every preset, morphs between a feed and a post, the edge-swipe back gesture, and on /islands: a boundary with derived and remembered skeletons, boundaries with fallbacks and retry, and islands loaded when idle, pressed or visible.
  • lint-showcase/: one deliberate warning for each lint rule (duolith lint examples/lint-showcase, then --fix), with a duolith.yaml that sets rule levels. It is the one example that does not lint clean.
  • packs/: an app with its own styling pack (building on Duolith's) and components pack (decision 0160): rules duolith lint checks as W0100, skills and references for agents, and the AGENTS.md section and subagents duolith packs sync --agents writes. It lints clean; duolith packs lists its packs.
  • upgrade/: one small app twice: edition-0.1/ written for edition 0.1, which duolith upgrade moves, and the upgraded app itself, which builds.
  • production/: consent (a banner and a privacy screen, with Global Privacy Control), analytics, crash reports and translation from @duolith/adapters, in English and Arabic (right to left), with a Reports screen showing what was sent; duolith scan examples/production checks its two vendored packages.
  • device-effects/: every device effect on the web, Android and iOS: location, sensors and the compass, device information, the connection, the keyboard, the display, contacts, the calendar, the clipboard, the media and file picker, the browser, biometrics, tracking, store reviews, the app badge, recording, speech and the barcode scanner. "Pretend to be a phone" puts each on its mock.
  • effects/: every platform effect on the web: sign-in (password, magic link, Apple and Google with PKCE against a mock backend and a pretend provider), a guarded account screen, key-value and secure storage, notifications with a permission explainer, camera, purchases (not available on the web, and a mock store), share, haptics, lifecycle and the minimum-version check. No network is used.
  • field-notes/: a small notes app with an app manifest in duolith.yaml (name, id, version and build, icon, launch screen, orientation, link domain and URL scheme), a /notes/[id] screen that links open, an href to another site and an environment value, for the native shells (docs/guide/native-apps.md).
  • typed-errors/: a recipe page with eight type errors on purpose (a misspelt field, a wrong word, a binding of the wrong type, data read before it loaded, a switch that misses a case), to show what duolith check reports. It does not build; expected.txt lists its exact errors, and its tests assert them in the build and the editor.

control-flow/, data/ and components/ have *.test.ts files: duolith test examples/data runs them (see docs/guide/testing.md). FEATURES.md lists each feature with captured output.

Every example builds and passes duolith fmt --check in CI, except typed-errors/, which fails on purpose and is only formatted.

Run one

cargo run -p duolith-cli -- dev examples/social     # http://localhost:4321, reloads on save
cargo run -p duolith-cli -- build examples/social   # static output in examples/social/dist

Run one on native

cargo run -p duolith-cli -- build examples/social --target native   # ReactLynx app in examples/social/dist-native
node packages/engine/scripts/bundle.ts examples/social/dist-native  # main.lynx.bundle for the shells in native/
node packages/engine/scripts/preview.ts examples/social/dist-native --port 4300   # in a browser, through Lynx for Web

Every example builds for native in CI; native/DEVICE-CHECKLIST.md lists what still needs a phone.

In this section