Files
kryon/docs/HTML_EXAMPLES.md
T

3.2 KiB

Runnable HTML and CSS examples in native TSX

The maintained dashboard project translates common HTML patterns into a native application: sidebar navigation, KPI cards, a searchable list, settings, loading, empty and error states. Its application entry is src/app.tsx; the complete screen composition and event wiring live in src/dashboard.tsx.

Run it from examples/dashboard/ with the normal project commands:

ziran fetch --locked
ziran build
ziran run

The same TSX screen builds through the declared portable or browser profile:

ziran tool kryon build portable
ziran tool kryon build web

The native model in src/model.zi contains records and filtering rules. Persistent edit buffers and actions live in src/dashboard_state.zi. The screen imports those checked declarations directly. Its native src/styles.zi parses and installs the CSS, including theme tokens, focus, hover and responsive rules.

For example, the screen's layout uses ordinary typed components:

import { Session } from "kryon/session";
import { Column, Row } from "kryon/tsx/layout";
import { Button } from "kryon/tsx/button";
import { Text } from "kryon/tsx/text";

export function SearchActions(session: Session): void {
    <Column session={session} props={{padding: s32(16), padding_override: true}}>
        <Text session={session} props={{text: "Filter cluster nodes"}}/>
        <Row session={session} props={{gap: s32(12), gap_override: true}}>
            <Button session={session} props={{label: "Apply"}}/>
            <Button session={session} props={{label: "Settings"}}/>
        </Row>
    </Column>;
}

The complete dashboard connects activations to real model actions, binds its TextField to stable native storage and scopes its settings modal. Copy that screen and model together when starting an application; the fragment above only illustrates composition.

Generate deterministic native previews, including each state and viewport:

mkdir -p build/previews
ziran tool kryon preview default --theme light --width 460,768,1120 --height 760 --output build/previews/dashboard
ziran tool kryon preview settings --theme dark --width 460 --height 760 --output build/previews/settings
ziran tool kryon preview responsive --width 460,768,1120 --height 760 --output build/previews/responsive

Each preview writes a PNG and the same retained semantic tree as JSON. The responsive fixture demonstrates measured grids, full-row cards and a horizontal ledger. Its stylesheet defines the tracks and breakpoints. The existing tests/responsive_dashboard_test.py checks placement, semantics and native/portable parity from the Kryon root; the dashboard README documents the complete verification commands.

Use HTML_TO_KRYON.md for the component mapping and supported CSS subset, or load ui-map.json for its checked TSX catalogue.