Getting started
Luca UI 1.0.3 Beta — a Beta release of the Luca UI 1.0 line. Everything on this page is implemented and tested; details may change before 1.0 stable.
What you will learn
By the end of this guide you will have:
- Installed the
luca-uiCLI. - Run your first
.lucufile and understood its output. - Added state so the UI derives its output from it.
- Connected an event to Luca Code logic in a
.luccfile. - Set up the VS Code extension.
How Luca UI fits together
Luca UI is not a general-purpose programming language. It is a thin, declarative UI layer on top of Luca Code, which is the general-purpose language of the Luca Ecosystem:
| File | Role | Owner |
|---|---|---|
.lucu | The UI description — components, state, bindings, events | Luca UI |
.lucc | The logic — functions, variables, flow | Luca Code |
The dependency is one-way: Luca UI reads .lucc logic through the published Luca Code library. Luca Code knows nothing about Luca UI. You can always run a .lucc file by itself with the luca CLI.
1. Requirements
For the prebuilt CLI: a supported platform (Linux x86_64, macOS arm64, Windows x86_64), curl or wget, and shasum or sha256sum to verify the download. No Rust toolchain is needed.
For building from source: Rust (stable) from rustup.rs and a Luca Code checkout placed next to your Luca UI checkout, with the folder name Luca Code:
Packages/
Luca Code/ ← Luca Code repository
Luca UI/ ← Luca UI repository (this one)
Why? The luca-ui package depends on luca-code by a relative path (../Luca Code) because Luca Code is not published to a registry yet. The Rust build reads the sibling checkout directly. If the sibling is missing, the build fails with a path-not-found error about ../Luca Code.
2. Install the CLI
Recommended — install the prebuilt binary:
curl -fsSL https://raw.githubusercontent.com/LucaEcosystem/luca-ui/main/install.sh -o install.sh
sh install.sh
export PATH="$HOME/.luca-ui/bin:$PATH"
The installer downloads the binary for your platform from the v1.0.3-beta release and checks it against the published SHA256SUMS. To use a different destination, set LUCA_UI_INSTALL_DIR.
Alternative — build from source (from the Luca UI directory):
cargo install --path . --root ~/.luca-ui
export PATH="$HOME/.luca-ui/bin:$PATH"
Verify:
luca-ui --version
luca-ui 1.0.3 Beta
3. Run your first UI file
Create a file hello.lucu:
-- My first Luca UI file.
App:
id = "app"
label = "Demo app"
Text:
id = "greeting"
text = "Hello, Luca!"
Run it:
luca-ui hello.lucu
App (2:1) id="app"
.id = "app"
.label = "Demo app"
Text (5:3) id="greeting"
.id = "greeting"
.text = "Hello, Luca!"
All outputs on this page are verified with luca-ui 1.0.3 Beta.
Reading the output:
- The file is parsed into a component tree — one root (
App), children nested by indentation. - Each component reports its props as
.key = valuelines. Textsits underAppbecause it is indented inside it.- The
(line:column)after each component is where that component was declared — that is where diagnostics will point. - There is no
visiblein the output because we did not declare it. Absentvisiblemeans the component is shown; nothing here hides anything unless you sayvisible = false.
This prints the declarative tree — validation plus structure, not pixels. Rendering is the job of backends (see Backends & rendering). This release ships a text backend that renders the resolved tree as structural lines and a static SVG backend that renders layout, paint, and text as vector primitives.
4. Make the UI derive from state
UI output is derived from state — there is no show(), hide(), or set_text() API in Luca UI (● locked design). You change state; the UI reacts.
Create first-state.lucu:
App:
id = "app"
state:
title = "Luca UI"
visits = 2
Text:
id = "title"
text = title
Text:
id = "counter"
text = visits
Run it:
luca-ui first-state.lucu
App (1:1) id="app"
.id = "app"
state (3:3)
.title = "Luca UI"
.visits = 2
Text (6:3) id="title"
.id = "title"
.text = title
Text (9:3) id="counter"
.text = visits
Two new things:
- The
state:block (underApp) declares typed variables. Types are inferred from the initial literal:titleisstr(a string),visitsisint. ◐ Assumption — thestate:block syntax works exactly like this, but is flagged as an assumption because the full design record may adjust it. text = title(no quotes) is a binding: the property takes its value from the state variabletitle. Quotedtext = "title"would be the literal texttitle. The CLI prints the declaration as written — the binding stays a bare name.
To see the resolved output (bindings substituted from state), render the tree with the text backend. TestHarness::render() does this, and it is the same resolution the toolchain performs before any backend runs (see Backends & rendering):
App id="app"
.id = "app"
Text id="title" label="Luca UI"
.id = "title"
.text = "Luca UI"
Text id="counter"
.id = "counter"
.text = 2
.text = titlebecame.text = "Luca UI", and.text = visitsbecame.text = 2.- The state block is not part of rendered output — rendered output is the component tree after state substitution.
label="Luca UI"appears automatically: when a component has no explicitlabel, its stringtextis offered as the accessible label (● locked accessibility inference — see Components).
See a static visual
The same resolved output can become an SVG snapshot. Add a layout:/style: block to the example above (or run the shipped one):
luca-ui render examples/visual.lucu --out visual.svg --width 320 --height 200
visual.svg contains <rect>/<text> primitives built from the documented ◐ layout/style subset. It is deliberately static: no interaction, platform fonts, or accessibility tree. To validate the view and see warnings about unrecognized visual values, use:
luca-ui check examples/visual.lucu
Details and the exact subset: Backends & rendering and Styling & theming.
5. Connect an event to logic
Events are the interaction boundary (● locked). A component declares an events: block mapping an event name to a handler name. The handler names logic that lives in the paired .lucc file.
events-demo.lucu:
App:
id = "app"
state:
visits = 0
greeting = "Hello, Luca!"
Text:
id = "greeting"
text = greeting
Button:
id = "visit"
text = "Visit"
events:
tap = record_visit
Run it:
luca-ui events-demo.lucu
App (1:1) id="app"
.id = "app"
state (3:3)
.visits = 0
.greeting = "Hello, Luca!"
Text (6:3) id="greeting"
.id = "greeting"
.text = greeting
Button (9:3) id="visit"
.id = "visit"
.text = "Visit"
events (12:5)
.tap -> record_visit
The events section prints the routing: event tap goes to handler record_visit.
The paired logic, events-demo.lucc (Luca Code syntax — full explanation in Core concepts):
def func record_visit(n (int)) (int):
return n + 1
def var visits = 0
visits = record_visit(visits)
print("visits = {visits}")
Running the logic file on its own with the luca CLI:
cargo run -p luca-code --manifest-path "../Luca Code/Cargo.toml" -- events-demo.lucc
visits = 1
How the two connect (● locked):
tap = record_visitdeclares that whenrecord_visitshould run for thetapevent — the.lucuside only names the handler; it never calls it.- Dispatch verifies the component id and the declared event and returns the handler name (see dispatch returns a name, not a call). Your application code decides when the handler runs.
There is no automatic .lucu→.lucc event hookup in this release (○ not implemented): the host application performs dispatch → run logic → state update → re-render. The render example and tests/events.rs in the repository show the full wiring.
When a sibling .lucc file exists, luca-ui check events-demo.lucu verifies that every declared handler has a top-level def func. Imports make that check unverified rather than failing (see CLI reference).
6. Set up the VS Code extension
The official extension ships with the repository: .lucu syntax highlighting, snippets, a starter-file command, and one-key run through the CLI. Install the local build:
code --install-extension editors/vscode/luca-ui-1.0.3.vsix
Details: VS Code extension.
Troubleshooting
Could not read ../Luca Code: … during install
The Luca Code checkout must be a sibling folder with that exact name. See Requirements.
An error like Error at line:column: message
Every failure is a source-located Luca error, and every possible message is cataloged. Two quick habits:
- The numbers point into your file —
Error at 2:3:is line 2, column 3. - Look the message up in the diagnostics catalog; each entry says what causes it.
'x' is not declared around a bare identifier
A bare identifier value (like text = title) is a binding. The name must be declared in a state: block somewhere in the tree before it can bind. Add it to a state: block.
Unknown property 'x' on component 'Text' (supports: …)
Registered core components (App, Text, Button) reject unknown property names — the error lists what each supports. See Components.
Where next
- Core concepts — the full
.lucugrammar reference, plus state and events. - Components —
App/Text/Buttonand the open component vocabulary. - Examples — every shipped example with verified output.