Skip to main content

Crate stucco

Crate stucco 

Source
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§

actionsactions
Actions (feature actions): buttons, button-styled links and icon buttons.
appapp
Page shells and page identity.
behavior
The client contract shared by Rust and the JavaScript behaviours.
collectionscollections
Server collections: native GET controls and typed table columns. With the derive feature, #[derive(Columns)] builds a row type’s columns from its fields.
datadata
Semantic data display.
el
The element builder: one function per HTML element (spec §4.4).
feedbackfeedback
Empty and status feedback.
formsforms
Forms (feature forms): form structure, controls and Field, which wires labels, hints and errors and binds to a submitted stucco_core::FormState.
icon
Icons: the Icon type (always available) and, with the icons feature, the vendored Lucide set as constants (icon::ARROW_RIGHT).
layoutlayout
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.
navigationnavigation
Server-rendered navigation.
overlayoverlay
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 axum feature the server setup.
theme
Themes: colours, scales, presets and contrast validation.
typographytypography
Typography (feature typography): headings, text, links, inline code and keyboard keys.

Macros§

register_asset
Registers a static Asset so Bundle serves its CSS and behaviour.

Structs§

Asset
A stylesheet chunk and/or client behaviour a component needs.
AssetFile
A file served by the bundle.
AssetRequirements
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.
CollectionPage
Owned rows and navigation metadata from one query.
CollectionQuery
Shareable, bounded collection query state.
ColumnSpec
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.
FormState
Values and errors from a form submission, keyed by field name.
Href
A URL safe to place in href, src and 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::label when it carries meaning on its own.
LabelledIcon
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.
RenderFn
A closure that renders; see render_fn.
RenderedFragment
A partial render: HTML plus the assets it needs.
ReturnContext
A local collection destination carried through detail pages and forms.
RevisionConflict
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.
ColorScheme
A forced colour scheme.
ColumnKind
Semantics of a declared column.
Delivery
How a page delivers its CSS and scripts.
Direction
Sort direction.
Filter
Validated filter value.
FlashLevel
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 Page and other documents.
Render
Anything that can write itself as HTML into a Cx.
WithBody
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 Render value.
render_fragment
Renders r as a fragment whose generated ids are prefixed with namespace (which must match [a-z0-9-]+ and be unique within the document the fragment is inserted into).
to_html
Renders r on its own and returns only the HTML.
ui_assets
Every asset registered by the enabled component families.