skeleton

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package skeleton provides shimmer placeholders rendered with pure CSS.

Use a skeleton during server-side data loads or while a signal-driven island fetches replacement HTML — render the skeleton in the initial HTML, then swap it for the real content when the data resolves.

All variants are visually-only: aria-hidden="true" so screen readers skip them and assistive tech announces the surrounding container's loading state instead.

CSP note: when Width or Height is set on Config, the resulting HTML carries a `style="inline-size:…;block-size:…"` attribute which a strict CSP (`default-src 'self'` without `style-src 'unsafe-inline'`) will block. For strict-CSP hosts, leave Width/Height empty (use the CSS defaults) or pass a custom Class and define the size in your stylesheet.

Index

Constants

This section is empty.

Variables

View Source
var Style = registry.RegisterStyle("skeleton", styleFn)

Style is the registered stylesheet handle. New's outermost element goes through Style.WrapHTML so the data-fui-comp marker is emitted and the runtime auto-loads the CSS on first appearance.

Functions

func New

func New(cfg Config) render.HTML

New renders one skeleton shape per Config. For multi-line skeletons, pass Count > 1 with Variant=Line.

Types

type Config

type Config struct {
	Variant Variant // default: Line
	Width   string  // CSS length, e.g. "100%", "12rem". Defaults vary by variant.
	Height  string  // CSS length. Default depends on variant.
	Count   int     // number of repeated lines (Line variant only). Default: 1.
	Class   string
	ID      string
}

Config configures a skeleton.

type Variant

type Variant string

Variant selects the skeleton shape.

const (
	Line   Variant = "line"   // single text line
	Block  Variant = "block"  // rectangular block (paragraphs, cards)
	Circle Variant = "circle" // circular (avatars)
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL