Skip to content

UI Engine Overview ​

Start with the guide

The way to build screens is a page with ui:* elements, opened with quantum start, quantum console or quantum desktop — see One App, Many Screens. The core set of elements listed there is drawn the same in the browser, the console and the desktop window (SPEC UI-7); the other elements on these reference pages work in the browser only and are Experimental. Examples below written as <q:application type="ui"> are standalone builds: layout only (UI-8).

The Quantum UI Engine is a cross-platform UI framework that allows you to build rich user interfaces using declarative XML syntax. Write once, deploy to HTML, Desktop, Mobile, or Terminal.

Key Features ​

  • 40+ UI Components - Forms, tables, cards, modals, charts, and more
  • Multi-Target Rendering - Single codebase compiles to multiple platforms
  • Design Tokens - Consistent styling across all targets
  • Reactive State - Automatic UI updates when state changes
  • Built-in Theming - Dark/light modes and custom themes
  • Animation System - Declarative animations with triggers

Getting Started ​

Basic UI Application ​

xml
<q:application id="myapp" type="ui" xmlns:q="https://quantum.lang/ns"
               xmlns:ui="https://quantum.lang/ui">

  <ui:window title="My First App">
    <ui:vbox padding="lg" gap="md">
      <ui:text size="2xl" weight="bold">Welcome to Quantum UI!</ui:text>
      <ui:button variant="primary">Click Me</ui:button>
    </ui:vbox>
  </ui:window>

</q:application>

Build Commands ​

bash
# Build for HTML (web browser) -> myapp.html
quantum run myapp.q --target html

# Build for Terminal (Textual TUI) -> myapp_console.py
quantum run myapp.q --target textual

# Build for Mobile (React Native, Laboratory) -> myapp.js
quantum run myapp.q --target mobile

# Desktop: --target desktop was removed in 0.16. Write the screens as pages
# in components/ and run them in a window with `quantum desktop`.

Component Categories ​

Layout Components ​

Control the structure and arrangement of UI elements.

ComponentDescription
ui:windowRoot container for UI applications
ui:hboxHorizontal layout container
ui:vboxVertical layout container
ui:gridCSS Grid-based layout
ui:panelBordered container with optional title
ui:tabsTabbed navigation container
ui:accordionCollapsible sections

Form Components ​

User input and form controls.

ComponentDescription
ui:formForm container with validation
ui:formitemLabel and input wrapper
ui:inputText input field
ui:buttonClickable button
ui:checkboxCheckbox input
ui:switchToggle switch
ui:selectDropdown select
ui:radioRadio button group

Data Display Components ​

Display and visualize data.

ComponentDescription
ui:tableData table with columns
ui:listOrdered/unordered lists
ui:treeHierarchical tree view
ui:chartData visualization charts

Feedback Components ​

User feedback and notifications.

ComponentDescription
ui:alertAlert messages
ui:loadingLoading spinners
ui:progressProgress bars
ui:badgeStatus badges
ui:skeletonLoading placeholders

Navigation and wayfinding.

ComponentDescription
ui:tabsTab navigation
ui:breadcrumbBreadcrumb trail
ui:paginationPage navigation
ui:menuNavigation menu

Overlay Components ​

Modals, tooltips, and dropdowns.

ComponentDescription
ui:modalModal dialogs
ui:tooltipHover tooltips
ui:dropdownDropdown menus

Advanced Components ​

Rich UI components for complex use cases.

ComponentDescription
ui:cardCard containers
ui:avatarUser avatars
ui:chartData charts

Design Tokens ​

Design tokens ensure consistent styling across all targets. Tokens are normalized values that translate to platform-specific implementations.

Spacing Tokens ​

TokenHTML ValueTerminal Value
xs4px1 char
sm8px1 char
md16px2 chars
lg24px3 chars
xl32px4 chars
xml
<ui:vbox padding="lg" gap="md">
  <!-- Content with large padding and medium gap -->
</ui:vbox>

Size Tokens ​

TokenDescription
autoAutomatic sizing
fillFill available space
1/250% width
1/333.3% width
1/425% width
2/366.6% width
3/475% width
xml
<ui:hbox>
  <ui:panel width="1/3">Sidebar</ui:panel>
  <ui:panel width="2/3">Main Content</ui:panel>
</ui:hbox>

Color Tokens ​

TokenDescription
primaryPrimary brand color
secondarySecondary color
successSuccess/positive state
dangerError/negative state
warningWarning state
infoInformational state
lightLight background
darkDark background
xml
<ui:button variant="primary">Submit</ui:button>
<ui:alert variant="success">Operation completed!</ui:alert>
<ui:badge variant="danger">Error</ui:badge>

Typography Tokens ​

TokenDescription
xsExtra small (12px)
smSmall (14px)
mdMedium (16px)
lgLarge (20px)
xlExtra large (24px)
2xl2x large (32px)
xml
<ui:text size="2xl" weight="bold">Large Heading</ui:text>
<ui:text size="sm" color="muted">Small helper text</ui:text>

Reactive State Binding ​

Bind UI components to state variables for automatic updates:

xml
<q:application id="counter" type="ui" xmlns:q="https://quantum.lang/ns"
               xmlns:ui="https://quantum.lang/ui">

  <q:set name="count" value="0" type="number" />

  <q:function name="increment">
    <q:set name="count" value="{count + 1}" />
  </q:function>

  <q:function name="decrement">
    <q:set name="count" value="{count - 1}" />
  </q:function>

  <ui:window title="Counter">
    <ui:vbox padding="lg" gap="md" align="center">
      <ui:text size="2xl">{count}</ui:text>
      <ui:hbox gap="sm">
        <ui:button on-click="decrement">-</ui:button>
        <ui:button on-click="increment">+</ui:button>
      </ui:hbox>
    </ui:vbox>
  </ui:window>

</q:application>

Event Handling ​

Click Events ​

xml
<ui:button on-click="handleClick">Click Me</ui:button>

<q:function name="handleClick">
  <q:set name="message" value="Button clicked!" />
</q:function>

Form Events ​

xml
<ui:form on-submit="handleSubmit">
  <ui:formitem label="Name">
    <ui:input bind="userName" />
  </ui:formitem>
  <ui:button type="submit">Submit</ui:button>
</ui:form>

Change Events ​

xml
<ui:input bind="searchQuery" on-change="handleSearch" />
<ui:select bind="selectedOption" on-change="handleSelection" />

Targets ​

HTML Target ​

Generates standalone HTML with CSS and JavaScript. Suitable for web applications.

bash
quantum run app.q --target html

Desktop Target ​

--target desktop was removed in 0.16. The same pages the browser serves run in a native window with quantum desktop (see Desktop).

bash
quantum desktop

Mobile Target ​

Generates React Native code for iOS and Android apps.

bash
quantum run app.q --target mobile   # writes app.js (Laboratory, see UI-8)

Terminal Target ​

Generates a Textual TUI application for terminal interfaces.

bash
quantum run app.q --target textual
python app_console.py  # Run in terminal

Complete Example ​

xml
<q:application id="taskmanager" type="ui" xmlns:q="https://quantum.lang/ns"
               xmlns:ui="https://quantum.lang/ui">

  <q:set name="tasks" value='[]' type="array" />
  <q:set name="newTaskName" value="" />
  <q:set name="filter" value="all" />

  <q:function name="addTask">
    <q:if condition="newTaskName != ''">
      <q:set name="tasks" operation="append" value='{
        "id": "{Date.now()}",
        "name": "{newTaskName}",
        "completed": false
      }' />
      <q:set name="newTaskName" value="" />
    </q:if>
  </q:function>

  <q:function name="toggleTask">
    <q:param name="taskId" type="string" />
    <!-- Toggle task completion -->
  </q:function>

  <ui:window title="Task Manager">
    <ui:vbox padding="lg" gap="md">

      <ui:header>
        <ui:text size="2xl" weight="bold">My Tasks</ui:text>
      </ui:header>

      <ui:form on-submit="addTask">
        <ui:hbox gap="sm">
          <ui:input
            bind="newTaskName"
            placeholder="Enter a new task..."
            width="fill"
          />
          <ui:button type="submit" variant="primary">Add</ui:button>
        </ui:hbox>
      </ui:form>

      <ui:tabs>
        <ui:tab label="All" active="{filter == 'all'}" on-click="setFilter('all')">
          <q:loop type="array" var="task" items="{tasks}">
            <ui:hbox gap="sm" padding="sm">
              <ui:checkbox
                checked="{task.completed}"
                on-change="toggleTask(task.id)"
              />
              <ui:text>{task.name}</ui:text>
            </ui:hbox>
          </q:loop>
        </ui:tab>
        <ui:tab label="Active">
          <!-- Active tasks -->
        </ui:tab>
        <ui:tab label="Completed">
          <!-- Completed tasks -->
        </ui:tab>
      </ui:tabs>

      <ui:footer>
        <ui:text color="muted">{tasks.length} tasks total</ui:text>
      </ui:footer>

    </ui:vbox>
  </ui:window>

</q:application>

Next Steps ​

Quantum Framework - Simplicity over configuration