nustack
ReferenceFabrics

nu.ui

Reactive UI fabric: Shape trees rendered live in the browser. Refs are backed by a client rendering surface (a browser tab), Interactions describe mutations the server ships as wire frames, and the host (nudle) owns the transport. Async-only. The widget kit lives under nu.ui.refs and is a separate reference; this page covers the fabric primitives.

Base

from nu.ui import Ref

NameSortSignatureEffectMeaning
RefclassRef(address, *, parent_ref=None, owner_shape=None)read/writebase Ref backed by a client rendering surface. Class name is the wire type; async-only.

Sections

from nu.ui import Section, SectionRef

NameSortSignatureEffectMeaning
SectionShapeclass MySection(Section): ...pureShape base for layout containers. Subclass to declare child Slots and pin chrome defaults.
SectionRefclassSectionRef(address, *, section_cls, parent_ref=None, owner_shape=None)read/writesubstrate Ref backing a Section Slot; attribute access descends into the bound Section's Slots.

Session

from nu.ui import Session, Subscription

NameSortSignatureEffectMeaning
SessionabstractSession()read/writewire transport for one client connection. Host binds a concrete impl on Context via ctx.bind(Session, ...).
SubscriptionProtocolSubscription() with bind/unbind/closeread/writeobserver handle returned by session.subscribe(path); callbacks fire when the client notifies on that path.

Wire

from nu.ui.core import Frame

NameSortSignatureEffectMeaning
FrameclassFrame(op, *, ref="", payload=None, id=None)pureone wire envelope, same shape both directions. op is a lifecycle string or an interaction instance (its lowercased class name becomes the wire op).

Interactions

from nu.ui import Write, Append, Changed

NameSortSignatureEffectMeaning
WriteCommandWrite(ref, value)mutates slot 0server-to-client: replace the Ref's value. Ships a write Frame on the bound Session.
AppendCommandAppend(ref, *values)mutates slot 0server-to-client: push onto a sequence-typed Ref. Multi-arg form ships the tuple, single-arg the value.
ChangedScalarQueryChanged(ref)puresubscribe to client-side change notifications. Resolves to a Subscription; sends no outbound Frame.

Nudle host

from nu.ui import Index, Page, Pages

NameSortSignatureEffectMeaning
IndexShapeclass App(Index): pages = Pages({...})read/writebrowser entrypoint. One per app. Declares structural Refs and a pages map; Refs on it use bare slot names as wire paths.
PageShapeclass Home(Page): ...read/writesub-Shape mounted at a route. Refs rooted on a Page resolve to <PageShapeName>.<slot>.
PagesclassPages({"/": Home, "/feed": Feed})puredeclarative URI-to-Page map. Class-attribute holder, not a Slot.

Nudle server

from nu.ui import NudleServer, NudleSession from nu.ui.nudle import server

NameSortSignatureEffectMeaning
NudleServerFabricLifecycleNudleServer(app, *, host="127.0.0.1", port=8080, log_level="info", ready_timeout=10.0, shutdown_timeout=5.0)read/writeboots the FastAPI + uvicorn stack that serves a nudle Index. Async-only; enters via Provide(NudleServer, {...}).
serverfnserver(app, *, host="127.0.0.1", port=8080, ...)pureconvenience wrapper: returns Provide(NudleServer, {...}) around a body.
NudleSessionSessionNudleSession(ws)read/writeconcrete Session over a FastAPI websocket. One per connection; owns the observer registry and pending reads.

Layout

from nu.ui import Row, Column, Container, Card, DividerRef, Field, Fieldset, Form, Modal, NavRef, Tabs, Accordion

Layout widgets are Section subclasses (Shape-based mounts) except DividerRef and NavRef, which are plain Refs. Sections use Cls.slot(**chrome) at declaration.

NameSortSignatureEffectMeaning
RowRefRow.slot(*, gap=4, align="center", justify="start", wrap=False, padding=0)purehorizontal flex Section.
ColumnRefColumn.slot(*, gap=4, align="stretch", justify="start", padding=0)purevertical flex Section.
ContainerRefContainer.slot(*, title="", padding="md", border="hairline", background="none", shadow="none", gap="md")purestyled box Section, pinned chrome.
CardRefCard.slot(*, title="", subtitle="", footer="")purecard Section with title, subtitle, body slots, footer.
DividerRefRefDividerRef.slot(*, label="", align="center")purehorizontal rule with optional label.
FieldRefField.slot(*, label="", help="", error="", required=False)purelabel plus one input child plus help/error text. Exactly one child slot.
FieldsetRefFieldset.slot(*, legend="", gap="md", disabled=False)puregrouped fields with a legend.
FormRefForm.slot(*, title="", gap=4, padding=0, align="stretch")puresemantic form wrapper; submit lives on a child ButtonRef.
ModalRefModal.slot(*, open=False, title="", dismissible=True)puredialog overlay; body Refs declared as child slots.
NavRefRefNavRef()read/writeIndex-level Ref bound to window.history + window.location. Push, replace, back, forward.
TabsRefTabs.slot(*, tabs=None, active="")puretab strip plus active body; one child slot per tab.
AccordionRefAccordion.slot(*, sections=None, open=None, multi=True)purestack of collapsible sections; tab owns open state.

Content

from nu.ui import TextRef, HeadingRef, TitleRef, MarkdownRef, ImageRef, LinkRef, BadgeRef, AlertRef, CodeBlockRef, JsonViewerRef

Server-owned display sinks (plus TitleRef, bound to document.title). Server pushes via write; browser renders, never reads back.

NameSortSignatureEffectMeaning
TextRefRefTextRef.slot(*, value="")pureplain body copy string.
HeadingRefRefHeadingRef.slot(*, label="", level=1, align="left")pureheading text with level and alignment.
TitleRefRefTitleRef.slot(*, default="", suffix="")pureIndex-level Ref bound to document.title. Write-only.
MarkdownRefRefMarkdownRef.slot(*, value="")purecommonmark source rendered inline.
ImageRefRefImageRef.slot(*, src="", alt="", fit="contain", width=None, height=None, rounded=False)pureimage sink with fit and sizing.
LinkRefRefLinkRef.slot(*, href="", label="", target="_self", external=None)purehyperlink with target and external hint.
BadgeRefRefBadgeRef.slot(*, label="", variant="neutral")puresmall tone-tagged label.
AlertRefRefAlertRef.slot(*, variant="info", title="", body="", dismissible=False)read/writebanner with tone, title, body; notify fires on dismiss.
CodeBlockRefRefCodeBlockRef.slot(*, code="", language="", show_copy=True)purefenced code block with optional copy control.
JsonViewerRefRefJsonViewerRef.slot(*, value=None, expand_depth=1, theme="light", copyable=False, sortable=False, max_height=None)purecollapsible JSON tree with depth and theme.

Input

from nu.ui import ButtonRef, InputRef, TextAreaRef, NumberInputRef, CheckboxRef, SwitchRef, RadioGroupRef, SelectRef, SliderRef, DatePickerRef, TagInputRef

Tab-owned Refs: browser holds the live value; host reads on demand via the Ref and subscribes to changed() / clicked().

NameSortSignatureEffectMeaning
ButtonRefRefButtonRef.slot(*, label="", variant="primary", disabled=False, icon=None)read/writeclick trigger; subscribe via .clicked().
InputRefRefInputRef.slot(*, label="", placeholder="", value="", type="text", max_length=None, mono=False)read/writesingle-line text input.
TextAreaRefRefTextAreaRef.slot(*, value="", placeholder="", rows=4, max_length=None, auto_resize=False, mono=False)read/writemulti-line text input.
NumberInputRefRefNumberInputRef.slot(*, label="", placeholder="", min=None, max=None, step=1.0, default=0.0)read/writenumeric input with step and bounds.
CheckboxRefRefCheckboxRef.slot(*, label="", checked=False)read/writeboolean toggle.
SwitchRefRefSwitchRef.slot(*, label="", default=False)read/writeon/off switch.
RadioGroupRefRefRadioGroupRef.slot(*, options=None, selected="", orientation="vertical")read/writesingle-choice radio group.
SelectRefRefSelectRef.slot(*, options=None, selected="", placeholder="")read/writedropdown single-select.
SliderRefRefSliderRef.slot(*, min=0.0, max=100.0, step=1.0, value=0.0, label="", show_value=True)read/writenumeric slider with range and step.
DatePickerRefRefDatePickerRef.slot(*, label="", placeholder="", min="", max="", default="")read/writedate input with ISO yyyy-mm-dd value.
TagInputRefRefTagInputRef.slot(*, label="", placeholder="", value=None, max_tags=None, allow_duplicates=False)read/writemulti-tag entry field.

Data display

from nu.ui import TableRef, StatRef, ProgressRef, GaugeRef

Server-owned sinks with structured payloads.

NameSortSignatureEffectMeaning
TableRefRefTableRef.slot(*, columns=None, striped=True, dense=False, max_rows=0, sort_column="", sort_direction="asc", clickable_rows=False)read/writetabular data with optional sort and row click.
StatRefRefStatRef.slot(*, label="", value="", delta="", trend="flat")puresingle KPI tile: label, value, delta, trend.
ProgressRefRefProgressRef.slot(*, value=0.0, caption="", indeterminate=False)purelinear progress bar with optional indeterminate mode.
GaugeRefRefGaugeRef.slot(*, value=0.0, caption="", variant="neutral")purearc gauge with tone variant.

Charts

from nu.ui import LineChart, BarChart, AreaChart, PieChart, Sparkline

Typed visualization sinks over series payloads. Server pushes via write (full/partial) and append (one row/point).

NameSortSignatureEffectMeaning
LineChartRefLineChart.slot(*, x_label="", y_label="", color="#2563eb", max_points=500, x_format="number", show_legend=False, show_tooltip=True, palette=None)puresingle- or multi-series line chart.
BarChartRefBarChart.slot(*, x_label="", y_label="", color="#2563eb", orientation="vertical", max_bars=200)purevertical or horizontal bar chart.
AreaChartRefAreaChart.slot(*, x_label="", y_label="", series=None, colors=None, stacked=False, max_points=500, x_format="number")purearea chart, stackable across series.
PieChartRefPieChart.slot(*, slices=None, colors=None, inner_radius=0.0, show_labels=True, show_legend=True, total_label="")purepie or donut chart with legend.
SparklineRefSparkline.slot(*, color="#2563eb", height=32, max_points=100)pureinline trend line.

On this page