Expand description
stucco: server-rendered, themeable, accessible UI components.
Render components into a Page backed by a Bundle:
use stucco::prelude::*;
let bundle = Bundle::new(Preset::Slate);
let html = Page::new(&bundle, "Hello")
.body(el::main().child(el::h1().text("Hello")))
.render();
assert!(html.contains("<h1>Hello</h1>"));Re-exports§
pub use stucco_tower as server;axum
Modules§
- actions
actions - Actions (feature
actions): buttons, button-styled links and icon buttons. - app
app - Page shells and page identity.
- behavior
- The client contract shared by Rust and the JavaScript behaviours.
- collections
collections - Server collections: native GET controls and typed table columns. With
the
derivefeature,#[derive(Columns)]builds a row type’s columns from its fields. - data
data - Semantic data display.
- el
- The element builder: one function per HTML element (spec §4.4).
- feedback
feedback - Empty and status feedback.
- forms
forms - Forms (feature
forms): form structure, controls andField, which wires labels, hints and errors and binds to a submittedstucco_core::FormState. - icon
- Icons: the
Icontype (always available) and, with theiconsfeature, the vendored Lucide set as constants (icon::ARROW_RIGHT). - layout
layout - Layout primitives (feature
layout): small composable building blocks that are responsive on their own. Parameters are data attributes, so layouts work under a strict CSP. - navigation
navigation - Server-rendered navigation.
- overlay
overlay - Overlays (feature
overlay): dialogs, menus, toasts and tooltips, built on native HTML (<dialog>, the popover API, invoker commands) so they need little or no script. One small behaviour module fills the gaps: invoker commands in browsers without them, menus anchored to their buttons, dismissible toasts and Escape for tooltips. - prelude
- The everyday imports: the page and theme types, the common components
of each enabled feature, their shared enums, and with the
axumfeature the server setup. - theme
- Themes: colours, scales, presets and contrast validation.
- typography
typography - Typography (feature
typography): headings, text, links, inline code and keyboard keys.
Macros§
- register_
asset - Registers a
staticAssetsoBundleserves its CSS and behaviour.
Structs§
- Asset
- A stylesheet chunk and/or client behaviour a component needs.
- Asset
File - A file served by the bundle.
- Asset
Requirements - The resolved, dependency-ordered assets a render required.
- Attrs
- A set of attributes: an id, classes and other attributes in insertion order. Components keep one for passthrough attributes and apply it to their root element.
- Bundle
- Every stylesheet and script a site needs, built once at startup.
- Capabilities
- Operations supported by a data source.
- Check
- A value being checked. After the first failed check, later checks are skipped, so each field records at most one message from its chain.
- Collection
- A loaded collection: the query parsed from a request, the backend’s capabilities, and the page of rows they produced. Hand it to a data table, which needs all three.
- Collection
Page - Owned rows and navigation metadata from one query.
- Collection
Query - Shareable, bounded collection query state.
- Column
Spec - Column identity and filter semantics.
- Cursor
- An opaque URL-safe cursor, bounded to 4096 ASCII characters.
- Cx
- The render context: output buffer, identity state and (later) asset requirements for one page or fragment.
- Flash
- Plain-text feedback carried across a redirect.
- Form
State - Values and errors from a form submission, keyed by field name.
- Href
- A URL safe to place in
href,srcand similar attributes. - Icon
- An inline SVG icon drawn on a 24×24 grid with Lucide’s stroke style.
Decorative by default (hidden from assistive technology); give it a label
with
Icon::labelwhen it carries meaning on its own. - Labelled
Icon - An icon with an accessible name (
role="img"). - Meta
- Document metadata.
- Page
- A complete HTML document.
- Raw
- Trusted markup rendered verbatim. This is the escape hatch for HTML; every use is a trust decision.
- Render
Fn - A closure that renders; see
render_fn. - Rendered
Fragment - A partial render: HTML plus the assets it needs.
- Return
Context - A local collection destination carried through detail pages and forms.
- Revision
Conflict - Opaque revisions from a rejected save. No ordering or comparison is implied.
- Slot
- Arbitrary renderable content held by a component.
- Validator
- Checks submitted values, recording one error message per field on the state so the form can be re-rendered.
Enums§
- Behavior
- Client-side code attached to an
Asset. - Color
Scheme - A forced colour scheme.
- Column
Kind - Semantics of a declared column.
- Delivery
- How a page delivers its CSS and scripts.
- Direction
- Sort direction.
- Filter
- Validated filter value.
- Flash
Level - The severity of a one-shot application message.
- Measure
- A width: 20, 30, 40, 60 or 75rem, or a comfortable reading measure (65ch).
- Size
- A visual size step.
- Space
- A step of the theme’s spacing scale (
--st-space-N). - Tone
- Text and status colour.
- Trend
- Which way a
Stat’s value moved. - Variant
- Emphasis of an action.
- Window
- Position within a collection.
Traits§
- PageExt
- Body shortcuts for
Pageand other documents. - Render
- Anything that can write itself as HTML into a
Cx. - With
Body - A document whose
<body>can be filled:Page, and documents built on it such as a server’s owned page. Component crates build shortcuts on this trait, such as filling the body with a main landmark.
Functions§
- check_
component_ css - Checks a stylesheet against the component CSS rules: no colour literals,
only semantic colour tokens (never palette steps), and everything inside
a
stucco.*cascade layer. - render_
fn - Wraps a closure as a
Rendervalue. - render_
fragment - Renders
ras a fragment whose generated ids are prefixed withnamespace(which must match[a-z0-9-]+and be unique within the document the fragment is inserted into). - to_html
- Renders
ron its own and returns only the HTML. - ui_
assets - Every asset registered by the enabled component families.