PulsarUI: Declarative Native UI Framework
PulsarUI: Declarative Native UI Framework
PulsarUI is the official native, declarative UI framework of Pulsar OS. It brings the SwiftUI programming model to Linux and across programming languages: your application describes a declarative view tree, the native runtime renders it using hardware acceleration and Liquid Glass materials, and your process owns the reactive state.
Unlike monolithic UI toolkits that tie developers to specific languages or heavy object models, PulsarUI is language-agnostic by design. The runtime is a standalone native binary (/usr/bin/pulsar-ui) communicating with client processes via newline-delimited JSON over standard I/O (stdin/stdout). A first-class Python SDK is provided out of the box, and bindings can be created effortlessly for Rust, Go, C++, Node.js, Zig, or Shell scripts.
1. Architectural Philosophy
graph LR
subgraph Client Application
State["Application State"] --> ViewTree["Declarative View Definition (Python / Rust / Go)"]
ViewTree --> JSON["JSON Lines Serializer"]
end
JSON -->|render / window / appearance| Stdio["Process Stdin"]
Stdio --> Runtime["PulsarUI Runtime (/usr/bin/pulsar-ui)"]
subgraph Native Runtime
Runtime --> Diff["Tree Reconciliation & Layout Engine"]
Diff --> RHI["Hardware Renderer (Vulkan / OpenGL)"]
Diff --> Glass["Liquid Glass & SF Typography Engine"]
end
Runtime -->|ready / event / quit| Stdout["Process Stdout"]
Stdout --> EventLoop["Client Event Dispatcher (@app.on)"]
EventLoop --> State
Core Design Pillars:
- Unidirectional State Flow: State drives the view (
State -> View). Whenever an event occurs (a button click, a text input, a timer tick), the client updates its internal state and re-renders a new view tree. - Language Agnostic: Any language capable of reading and writing newline-delimited JSON over standard pipes can create native, GPU-accelerated desktop apps.
- Pulsar Liquid Glass Aesthetics: Native support for frosted acrylic materials, smooth corner radii, responsive layouts, and Apple SF Symbols.
- Thread-Safe & Non-Blocking: UI callbacks and async background workers are isolated. Applications remain fluid and responsive without freezing the window thread.
2. Installation & Setup
PulsarUI is included by default in all official Pulsar OS installations as a core system component.
On Pulsar OS / Arch Linux:
sudo pacman -S pulsar-ui
Python SDK Availability:
The Python SDK is packaged directly with the runtime and installed into standard system site-packages:
import pulsarui
No external pip dependencies are required.
3. Quickstart Example (Python)
Below is a complete, standalone PulsarUI application demonstrating a modern system utility with a sidebar, form controls, and live state updates:
from pulsarui import (
App,
Button,
Card,
Divider,
HStack,
Icon,
Label,
NavigationSplitView,
ProgressView,
Sidebar,
SidebarItem,
Spacer,
TextField,
Toggle,
VStack,
)
app = App("Pulsar Cloud Manager", width=780, height=520)
state = {
"selected_tab": "general",
"sync_enabled": True,
"bandwidth_limit": "50 MB/s",
"progress": 0.65,
}
def view():
tab = state["selected_tab"]
# 1. Sidebar navigation
sidebar = Sidebar([
SidebarItem("General", "general", "gear"),
SidebarItem("Almacenamiento", "storage", "cloud"),
SidebarItem("Seguridad", "security", "lock.shield"),
], selection=tab)
# 2. Main content panels
if tab == "general":
content = VStack([
Label("Configuración General", font="title1", weight="bold"),
Label("Administra la sincronización de tu unidad en la nube", color="secondary"),
Divider(),
Card(
VStack([
HStack([
Label("Sincronización Automática", font="headline"),
Spacer(),
Toggle(value=state["sync_enabled"], id="toggle_sync"),
], align="center"),
Label("Sincronizar archivos locales con el almacenamiento remoto en segundo plano", color="secondary", font="caption"),
], spacing=6),
inset=16
),
Card(
VStack([
Label("Límite de Ancho de Banda", font="headline"),
HStack([
TextField(value=state["bandwidth_limit"], id="input_limit", width=220),
Button("Aplicar", id="btn_apply", role="default"),
], spacing=8),
], spacing=8),
inset=16
),
Spacer(),
], spacing=16, padding=(24, 28))
else:
content = VStack([
Label("Estado del Almacenamiento", font="title1", weight="bold"),
ProgressView(value=state["progress"], style="bar"),
Label("65 GB utilizados de 100 GB disponibles", color="secondary", font="callout"),
Spacer(),
], spacing=14, padding=(24, 28))
return NavigationSplitView(sidebar, content, sidebar_width=210)
# Event Handlers
@app.on("toggle_sync")
def _on_toggle(val):
state["sync_enabled"] = bool(val)
app.render()
@app.on("select")
def _on_nav(val):
state["selected_tab"] = val
app.render()
@app.on("btn_apply")
def _on_apply(_val):
print("Aplicando configuración...")
if __name__ == "__main__":
app.run(view)
4. Comprehensive Component Reference
Every PulsarUI element is a pure, immutable view node. Components are composed hierarchically into stacks, cards, and forms.
4.1 Layout & Containers
VStack (Vertical Stack)
Arranges child elements sequentially in a vertical column.
VStack(
children=[...], # List of child view nodes
spacing=10, # Spacing between children in logical pixels (default: 8)
align="leading", # Alignment: 'leading', 'center', 'trailing'
padding=(16, 20), # Optional padding: int or (v_pad, h_pad)
width=None, # Fixed width or None
height=None # Fixed height or None
)
Example:
VStack([
Label("Título de la Sección", font="headline"),
Label("Descripción detallada del contenido que se mostrará aquí.", color="secondary", font="subheadline"),
], spacing=4, align="leading")
HStack (Horizontal Stack)
Arranges child elements sequentially in a horizontal row.
HStack(
children=[...], # List of child view nodes
spacing=12, # Spacing between children in logical pixels (default: 8)
align="center", # Vertical alignment: 'top', 'center', 'bottom'
padding=8 # Optional internal padding
)
Example:
HStack([
Icon("wifi", size=20, color="accent"),
Label("Red Inalámbrica Conectada"),
Spacer(),
Button("Desconectar", id="btn_disconnect", role="borderless")
], spacing=10, align="center")
ZStack (Depth / Overlay Stack)
Layers child elements on top of each other along the Z axis (depth). Elements declared later render on top of earlier elements.
ZStack(
children=[...], # List of child view nodes from bottom to top
align="center" # Alignment of children within the stack
)
Example (Badge overlay on an icon):
ZStack([
Icon("bell", size=28),
HStack([
Spacer(),
VStack([
Shape(type="circle", fill="#FF3B30", width=10, height=10),
Spacer()
])
])
])
Scroll (Scrollable Area)
Wraps a single view node (typically a VStack) and provides native smooth inertia scrolling.
Scroll(
child, # Single view node (usually a VStack)
axes="vertical", # 'vertical', 'horizontal', or 'both'
shows_indicators=True # Whether scrollbars are visible
)
Example:
Scroll(
VStack([
Card(Label(f"Elemento {i}"), inset=12) for i in range(100)
], spacing=8, padding=16),
axes="vertical"
)
Card (Liquid Glass Surface)
Surrounds child views with a styled macOS-like card container featuring corner rounding, subtle border reflections, and optional acrylic backdrop blur.
Card(
child, # The child view node inside the card
inset=16, # Inner padding around child (default: 12)
radius=12, # Corner radius in logical pixels (default: 12)
material="glass", # Material: 'glass' (frosted acrylic), 'solid', 'sidebar'
stroke=True # Subtle outer border highlight
)
Example:
Card(
HStack([
Icon("icloud", size=32, color="accent"),
VStack([
Label("Pulsar Drive", font="headline"),
Label("Sincronizado hace 2 minutos", color="secondary", font="caption"),
], spacing=2),
Spacer(),
Button("Opciones", id="btn_options", role="default")
], align="center"),
inset=14,
material="glass"
)
Form & Section (Settings Forms)
Structures controls into grouped sections with automatic row separators, header labels, and footer captions.
Form([
Section(
title="Dispositivos de Entrada",
rows=[
FormRow("Micrófono", Picker(["Interno", "USB Headset"], selected="USB Headset", id="mic_picker")),
FormRow("Volumen de Entrada", Slider(value=75, id="mic_vol")),
],
footer="Ajusta la sensibilidad del micrófono para llamadas."
)
])
NavigationSplitView (Master-Detail Pane)
Two-column master/detail layout standard in macOS and Pulsar OS system apps.
NavigationSplitView(
sidebar, # The left navigation Sidebar view
detail, # The right main detail view
sidebar_width=220, # Initial sidebar width in pixels
min_sidebar_width=180, # Minimum draggable width
max_sidebar_width=320 # Maximum draggable width
)
Sidebar & SidebarItem
Creates a macOS source-list sidebar with active selection indicators.
Sidebar(
items=[
SidebarItem("General", id="tab_general", icon="gear"),
SidebarItem("Pantalla", id="tab_display", icon="display"),
SidebarItem("Sonido", id="tab_sound", icon="speaker.wave.2"),
],
selection="tab_general" # Currently selected item ID
)
Grid (Responsive Grid)
Distributes child elements in uniform rows and columns.
Grid(
children=[...], # List of elements
columns=3, # Number of equal columns
spacing=12 # Spacing between cells
)
4.1.1 Apple Liquid Glass & Vibrancy Components
PulsarUI provides direct, first-class primitives for visionOS and macOS Tahoe Liquid Glass translucent materials. These elements feature dynamic backdrop blur, specular refraction, 1px highlight strokes, and vibrancy:
GlassCard (Frosted Vibrancy Container)
A depth container rendered with real-time backdrop blur and translucent acrylic tinting.
GlassCard(
child, # Single view node (e.g. VStack)
material="glass", # Material: 'glass', 'acrylic', 'hud', 'clear'
corner_radius=18, # Rounded corner radius in pixels
border_highlight=True, # Specular top/outer edge highlight stroke
inset=16 # Internal content padding
)
Example:
GlassCard(
VStack([
Label("Panel de Control Traslúcido", font="headline"),
Label("El fondo del escritorio se difumina en tiempo real tras esta tarjeta.", color="secondary"),
], spacing=8),
corner_radius=20,
inset=18
)
LiquidGlassBar (Floating Pill Toolbar)
A floating navigation capsule or toolbar styled like Apple’s visionOS and macOS Tahoe floating control strips.
LiquidGlassBar(
children=[...], # Horizontal toolbar buttons and controls
spacing=12, # Spacing between actions
corner_radius=24, # High-curvature pill radius
padding=(8, 16) # (vertical, horizontal) padding
)
Example:
LiquidGlassBar([
Button("Atrás", id="back", icon="chevron.left", role="borderless"),
Spacer(),
Label("Documento Sin Título", font="headline"),
Spacer(),
GlassButton("Compartir", id="share", icon="square.and.arrow.up"),
], spacing=10)
GlassButton (Specular Glass Pill Button)
An authentic macOS-style pill button featuring a translucent dark glass background, smooth pill curvature, and a delicate 1px border highlight (avoiding heavy beveled relief).
GlassButton(
title, # Button label
id="btn_id", # Event handler identifier
icon="play", # Optional SF Symbol icon
prominent=False # Whether to apply accent glow
)
Example:
GlassButton("Desconectar", id="btn_disconnect", icon="xmark")
Spacer & Divider
Spacer(): Flexibly expands to consume all available space along the parent stack’s axis.Divider(): A 1-pixel hairline separator styled to match the active light or dark theme.
HStack([
Label("Izquierda"),
Spacer(), # Pushes right elements to the far right edge
Label("Derecha")
])
4.2 Controls & User Inputs
Button
Clickable push button supporting Apple human-interface button roles.
Button(
title="Aceptar", # Text title
id="btn_submit", # Unique event ID
icon=None, # Optional SF Symbol name (e.g. 'plus', 'checkmark')
role="default", # Roles: 'default', 'prominent', 'destructive', 'borderless', 'glass'
disabled=False, # Boolean disabled state
width=None # Fixed width
)
Roles explained:
role="default": Clean flat pill-shaped button.role="prominent": Accent-colored primary action (e.g. Save, Install).role="destructive": Red-tinted button for irreversible actions (e.g. Delete, Disconnect).role="borderless": Text or icon button without background frame until hovered.role="glass": Translucent Liquid Glass floating capsule.
Event: Emits click action with None value when pressed.
Toggle (Switch)
Smooth animated sliding toggle switch for boolean preferences.
Toggle(
value=True, # Boolean state (True/False)
id="toggle_bluetooth", # Unique event ID
disabled=False
)
Event: Emits change action with boolean value True or False.
Checkbox
Standard checkbox with integrated label.
Checkbox(
label="Iniciar sesión al arrancar el equipo",
value=False,
id="cb_autostart"
)
Event: Emits change action with boolean value True or False.
TextField & SearchField
Interactive single-line text input fields.
TextField(
value="texto inicial",
placeholder="Escribe aquí...",
id="input_text",
width=240,
secure=False # True for password mask
)
SearchField(
value="",
placeholder="Buscar ajustes o archivos...",
id="search_query",
width=280
)
Events:
- Emits
changeaction whenever text is typed. - Emits
submitaction when the user presses Enter.
Slider
Continuous or stepped slider for volume, brightness, or percentage values.
Slider(
value=65.0, # Current numeric value
min=0.0, # Minimum bound
max=100.0, # Maximum bound
step=1.0, # Step increment (or 0 for continuous)
id="volume_slider",
width=220
)
Event: Emits change action with float value.
Stepper
Paired + / - increment buttons.
Stepper(
value=3,
min=1,
max=10,
step=1,
id="step_copies"
)
Event: Emits change action with int/float value.
Picker (Dropdown or Segmented)
Selection among mutually exclusive options.
Picker(
options=["Automático", "Claro", "Oscuro"],
selected="Automático",
id="picker_theme",
style="segmented" # 'segmented' or 'menu' (dropdown popover)
)
Event: Emits change action with selected string value.
Menu (Popup Button)
Clickable button that presents a contextual popup menu.
Menu(
title="Acciones",
items=[
MenuItem("Abrir archivo", id="act_open", icon="folder"),
MenuItem("Duplicar", id="act_dup", icon="plus.square"),
MenuItem("Eliminar", id="act_del", icon="trash", destructive=True),
],
id="popup_menu"
)
Event: Emits select action with selected item ID.
ProgressView & Gauge
Visual task progress indicators.
# Linear progress bar (0.0 to 1.0)
ProgressView(value=0.45, style="bar", width=260)
# Indeterminate spinning loader
ProgressView(style="spinner")
# Circular status gauge
Gauge(value=82, min=0, max=100, label="82%", style="circular")
4.3 Typography & Content
Label
Renders typography adhering to the macOS / SF Pro font scale.
Label(
text="Hola Pulsar",
font="body", # Font scale: 'largeTitle', 'title1', 'title2', 'title3',
# 'headline', 'subheadline', 'body', 'callout', 'caption', 'footnote'
weight="regular", # Weight: 'regular', 'medium', 'semibold', 'bold'
color="primary", # Color: 'primary', 'secondary', 'tertiary', 'accent', or hex '#RRGGBB'
line_limit=None, # Max lines before truncating with ellipsis (None for unlimited)
align="left" # 'left', 'center', 'right'
)
Icon (SF Symbols)
Renders high-resolution vector icons mapped to the standard SF Symbol library.
Icon(
name="speaker.wave.3", # Symbol name: 'gear', 'cloud', 'wifi', 'display', 'trash', etc.
size=20, # Size in logical pixels
color="accent" # Color name or hex
)
Image
Renders bitmap assets from local filesystem paths or base64 data.
Image(
src="/usr/share/icons/pulsar/logo.png",
width=64,
height=64,
fit="contain", # 'contain', 'cover', 'fill'
radius=8 # Optional corner rounding
)
Shape
Geometric vector shapes for indicators, backgrounds, or custom separators.
Shape(
type="capsule", # 'rectangle', 'rounded_rectangle', 'capsule', 'circle'
fill="#007AFF", # Fill color or None
stroke="#0051A8", # Border color or None
stroke_width=1.5,
width=80,
height=28
)
5. Reactive State & Event Handling
PulsarUI follows the Unidirectional Reactive Architecture:
- State is kept in plain data structures (e.g. Python
dictor class instance). - The
view()function converts current state into a tree of immutable view nodes. - User interactions generate events dispatched to handlers registered with
@app.on(id). - Event handlers modify state and invoke
app.render(). - The PulsarUI native runtime computes a tree diff and updates the GPU scene graph smoothly with zero flicker.
Complete Event Dispatching Example:
from pulsarui import App, VStack, HStack, Label, Button, TextField
app = App("Reactive Counter", width=400, height=260)
state = {
"count": 0,
"step_size": "1"
}
def view():
return VStack([
Label(f"Valor: {state['count']}", font="largeTitle", weight="bold"),
HStack([
Button("- Disminuir", id="btn_dec", role="default"),
Button("+ Aumentar", id="btn_inc", role="prominent"),
], spacing=10),
HStack([
Label("Paso:", color="secondary"),
TextField(value=state["step_size"], id="input_step", width=60),
], spacing=8, align="center")
], spacing=16, padding=24, align="center")
@app.on("btn_inc")
def _handle_inc(_val):
step = int(state["step_size"]) if state["step_size"].isdigit() else 1
state["count"] += step
app.render()
@app.on("btn_dec")
def _handle_dec(_val):
step = int(state["step_size"]) if state["step_size"].isdigit() else 1
state["count"] -= step
app.render()
@app.on("input_step")
def _handle_step(val):
state["step_size"] = val
# No render required on simple keypress unless UI depends on it
app.run(view)
6. Asynchronous Tasks & Timers
PulsarUI guarantees smooth 60fps window rendering by isolating long-running operations from the UI event loop.
6.1 Timers: app.after(delay_seconds, callback)
Schedules a non-blocking callback to run on the main event thread after a given delay.
# Dismiss a notification banner after 3 seconds:
def show_toast(message):
state["toast_message"] = message
app.render()
def _auto_dismiss():
state["toast_message"] = None
app.render()
app.after(3.0, _auto_dismiss)
6.2 Background Workers: app.async_call(worker_fn, on_done_fn)
Executes heavy computations or blocking CLI commands in a background worker thread. When finished, the completion handler safely receives the result on the main UI thread.
import subprocess
def test_speakers():
state["testing"] = True
app.render()
def _background_work():
# Executes heavy process in background thread
res = subprocess.run(["canberra-gtk-play", "-i", "audio-channel-front-left"], capture_output=True)
return res.returncode == 0
def _on_finished(success):
# Runs on UI thread when work finishes
state["testing"] = False
state["test_result"] = "Éxito" if success else "Error"
app.render()
app.async_call(_background_work, _on_finished)
7. Multi-Language Wire Protocol (v1)
The PulsarUI native runtime (/usr/bin/pulsar-ui) can be embedded into any programming language using standard streams.
Handshake & Lifecycle:
- Client starts child process:
/usr/bin/pulsar-ui - Runtime outputs ready handshake:
{"type":"ready","protocol":1,"runtime":"pulsar-ui"} - Client sends window and render tree:
{ "type": "render", "window": { "title": "Mi App en Rust", "width": 640, "height": 400 }, "body": { "type": "vstack", "spacing": 12, "children": [ {"type": "label", "text": "Hola desde Rust", "font": "title2"}, {"type": "button", "id": "btn_click", "text": "Presióname", "role": "prominent"} ] } } - User clicks button, runtime sends event on stdout:
{"type":"event","id":"btn_click","action":"click","value":null} - Window closed by user:
{"type":"closed"}
Building Clients in Rust:
use std::io::{BufRead, BufReader, Write};
use std::process::{Command, Stdio};
fn main() {
let mut child = Command::new("pulsar-ui")
.stdin(Stdio::piped())
.stdout(Stdio::piped())
.spawn()
.expect("Failed to start pulsar-ui");
let mut stdin = child.stdin.take().unwrap();
let stdout = child.stdout.take().unwrap();
let mut reader = BufReader::new(stdout);
// Read ready line
let mut line = String::new();
reader.read_line(&mut line).unwrap();
// Send render JSON
let initial_view = r#"{"type":"render","window":{"title":"Rust UI"},"body":{"type":"button","id":"b1","text":"Hola"}}"#;
writeln!(stdin, "{}", initial_view).unwrap();
// Event loop
for event_line in reader.lines() {
let event_json = event_line.unwrap();
println!("Received event: {}", event_json);
}
}
8. Summary Table: PulsarUI vs. GTK4 / Libadwaita
| Feature | PulsarUI | GTK4 / Libadwaita |
|---|---|---|
| Programming Paradigm | Declarative (State -> View) | Imperative Object Trees |
| Language Portability | Universal via JSON Protocol (Python, Rust, Go, Zig…) | C-centric (GObject Introspection, complex bindings) |
| Look & Feel | Native Liquid Glass & macOS Styling | Adwaita Linux Styling |
| Boilerplate Code | Extremely low (pure declarative tree) | High (XML UI files, signals, mutable handles) |
| Crash Isolation | Client crash does not corrupt compositor | In-process toolkit faults can crash application |
| Threading Model | Automatic UI / background thread isolation | Manual g_idle_add / GTask marshaling |
9. Next Steps
- Explore the
/usr/lib/python*/site-packages/pulsarui/codebase for internal implementation details. - Review
pulsar-cloud-wizardfor a production-ready application using asynchronous background workers and form wizards.
Any doubts or questions?
Join the Inled community