LeanUI Docs
← Open LeanUI Studio GitHub

Tutorial 2 · Build a Styled Task Tracker (5 Visual Steps)#

Now that you know the core MVU + Lean 4 loop from Tutorial 1, let's build a richer real-world app — StyledTaskTracker — using typed record Collections (List TaskItem), list capacity invariants, WCAG AAA StyleTokens, EN/DE Resource Dictionaries, sortable Data Tables, and 3D Isometric Orbit Timeline inspection.

Follow along live in your browser: https://wieslawsoltes.github.io/LeanUI/ Every step snapshot below is auto-generated directly from the live LeanUI SVG engine on each deployment. Click any figure to zoom (⤢ Zoom).


Step 1 · Define a Typed Collection (List TaskItem) & Draft State#

Collections model typed tables/lists (List Row) with compile-time field schemas checked in both TypeScript and Lean 4.

How to Do This in LeanUI Studio#

  1. Create a new module named StyledTaskTracker via ⊞ Solution → + Module.
  2. Drag a Collection node from the Node Palette onto the canvas and configure it in the Node Inspector:
    • Name: tasks · Item Type Name: TaskItem
    • Schema Columns: title : String, priority : Nat, done : Bool
    • Seed Rows: add 2 initial tasks ("Verify Lean proofs", "Ship responsive UI").
  3. Drag a State node (draftTitle : String, init: "Write docs") for the new-task form input.
  4. Drag a Computed node (taskCount : Nat, expression: tasks.length) and wire tasks.items → taskCount.in.
LIVE GENERATED SVG · AUTO-UPDATED ON BUILD
Open SVG ↗
Step 1 Snapshot — Typed Collection (List TaskItem), draftTitle State & derived taskCount metric Step 1 Snapshot — Typed Collection (List TaskItem), draftTitle State & derived taskCount metric
Step 1 Snapshot — Typed Collection (List TaskItem), draftTitle State & derived taskCount metric

Step 2 · Add Collection Actions & Prove List Capacity Bounds#

Add safe list mutations (AddTask, ClearAll) and a Lean 4 Invariant ensuring the task list never grows unboundedly.

How to Do This in LeanUI Studio#

  1. Add an Action node named AddTask:
    • Expression: tasks = tasks.length < 20 ? tasks.concat([{ title: draftTitle, priority: 1, done: false }]) : tasks
    • Wire AddTask.effect → tasks.mutate.
  2. Add a second Action node named ClearAll:
    • Expression: tasks = []
    • Wire ClearAll.effect → tasks.mutate.
  3. Add an Invariant node named boundedList:
    • Expression: tasks.length <= 20
    • Wire tasks.items → boundedList.check.
LIVE GENERATED SVG · AUTO-UPDATED ON BUILD
Open SVG ↗
Step 2 Snapshot — Guarded AddTask/ClearAll collection actions and boundedList Lean 4 invariant Step 2 Snapshot — Guarded AddTask/ClearAll collection actions and boundedList Lean 4 invariant
Step 2 Snapshot — Guarded AddTask/ClearAll collection actions and boundedList Lean 4 invariant

Checkpoint: Verify the Console shows 0 errors — LeanUI statically type-checks the record literal { title, priority, done } against TaskItem's schema!


Step 3 · Add a WCAG AAA StyleToken & EN/DE Resource Bundle#

LeanUI verifies your visual design system with the exact same mathematical rigor as your application logic.

How to Do This in LeanUI Studio#

  1. Drag a Style Token (style) node from the Design System section of the Palette:
    • Name: TaskSurface
    • Background: #0f172a · Foreground: #f8fafc · Accent: #38bdf8
    • Look at the node's preview strip — LeanUI computes the exact WCAG contrast ratio (17.8:1 ✓ AAA) automatically!
  2. Drag a Resource Bundle (resource) node next to it:
    • Name: TaskStrings · Locales: en, de
    • Add localized entries (title, add) and a theme token (surfaceBg with Light #ffffff / Dark #0f172a).
LIVE GENERATED SVG · AUTO-UPDATED ON BUILD
Open SVG ↗
Step 3a Snapshot — WCAG AAA StyleToken (17.8:1) and multi-locale EN/DE Resource Dictionary Step 3a Snapshot — WCAG AAA StyleToken (17.8:1) and multi-locale EN/DE Resource Dictionary
Step 3a Snapshot — WCAG AAA StyleToken (17.8:1) and multi-locale EN/DE Resource Dictionary

Inspect & Tune Contrast Live in the Property Inspector#

  • Click TaskSurface on the canvas and inspect its live WCAG contrast badge (17.8:1 ✓ AAA), border radius, padding, and device sizing controls in the ⚙ Inspector panel.
LIVE GENERATED SVG · AUTO-UPDATED ON BUILD
Open SVG ↗
Step 3b Focused Panel Snapshot — Editing TaskSurface StyleToken & Checking WCAG AAA Contrast in Property Inspector Step 3b Focused Panel Snapshot — Editing TaskSurface StyleToken & Checking WCAG AAA Contrast in Property Inspector
Step 3b Focused Panel Snapshot — Editing TaskSurface StyleToken & Checking WCAG AAA Contrast in Property Inspector

Tip: Want reusable multi-part controls? Add a Control Template (control_template) node and double-click it to enter the unified ❖ ControlTemplate visual graph editor (see Control Templates & Design).


Step 4 · Wire the Styled Card, Form Input, Button & Sortable Table#

Connect your design tokens, draft form state, and typed collection into an interactive UI.

How to Do This in LeanUI Studio#

  1. Add a Card (TaskBoard, Title: "Task Tracker") and wire:
    • TaskSurface.style → TaskBoard.style
    • TaskStrings.res → TaskBoard.res
  2. Add four children wired from TaskBoard.children → parent:
    • Stat (OpenTasksStat) ← taskCount.out → value
    • Input (DraftInput, Label: "New Task") ← draftTitle.val → value
    • Button (AddTaskBtn, Label: "+ Add Task") → onClick → AddTask.trigger
    • Table (TaskTable, columns: Title | Priority | Done, Striped & Removable) ← tasks.items → rows
  3. Click Layout (DAG Layered) and ⊡ Size (Auto-Size All) to make every card crisp and spacious.
LIVE GENERATED SVG · AUTO-UPDATED ON BUILD
Open SVG ↗
Step 4a Snapshot — Complete StyledTaskTracker graph with live evaluated values, WCAG styles & sortable Table binding Step 4a Snapshot — Complete StyledTaskTracker graph with live evaluated values, WCAG styles & sortable Table binding
Step 4a Snapshot — Complete StyledTaskTracker graph with live evaluated values, WCAG styles & sortable Table binding

Test the Live App End-to-End Across All Studio Panels#

  • Type a new task into New Task inside the right-hand ▶ Preview panel, click + Add Task, scrub the ⏱ Timeline slider below it, and verify 0 errors in ▤ Console.
LIVE GENERATED SVG · AUTO-UPDATED ON BUILD
Open SVG ↗
Step 4b Full Studio Workspace Snapshot — Running StyledTaskTracker Live Across Preview, Timeline & Console Step 4b Full Studio Workspace Snapshot — Running StyledTaskTracker Live Across Preview, Timeline & Console
Step 4b Full Studio Workspace Snapshot — Running StyledTaskTracker Live Across Preview, Timeline & Console

Try it live: Click column headers in the rendered TaskTable to sort rows, click row remove icons, and toggle the Locale dropdown (EN ↔ DE)!


Step 5 · Inspect in 3D Orbit & Export Diagrams or Multi-Screen Prototype#

  1. Dispatch 2–3 AddTask clicks in Live Preview, then switch to 🧊 3D Orbit in the center stage bar to watch each new task stack as a 3D frame linked by state-diff arcs.
  2. Click λ Prove to machine-check all state, collection, WCAG contrast, and i18n theorems in Lean 4.
  3. Click ⤓ Export in the Canvas HUD to export your app as:
    • Crisp SVG or 2×/3× Retina PNG (with Auto-Annotate Help Callouts), or
    • A Multi-Page PDF Architecture Deck containing Clean Graph, Live State, Timeline Storyboard, CAD Explode, 3D Orbit, and App Flow!
LIVE GENERATED SVG · AUTO-UPDATED ON BUILD
Open SVG ↗
Step 5 Snapshot — StyledTaskTracker state transitions stacked in 3D Isometric Orbit Timeline Step 5 Snapshot — StyledTaskTracker state transitions stacked in 3D Isometric Orbit Timeline
Step 5 Snapshot — StyledTaskTracker state transitions stacked in 3D Isometric Orbit Timeline

Continue Learning#

Diagram Preview
Enlarged diagram