Next: , Previous: , Up: API  


1.10 (hygguile components feedback)

1.10.1 Procedures

Procedure: alert KEY: #:title #:body #:variant #:role #:icon #:alert-classes

Create an accessible inline alert or callout box.

Alerts are plain HTML and CSS, so they continue to render and be announced by assistive technology when JavaScript is disabled.

title

An optional short, bold heading for the alert.

body

The alert message text or inline nodes.

variant

A semantic keyword: 'info (default), 'success, 'warning, 'danger or 'neutral.

role

An optional ARIA role override. Defaults to alert for danger and status for every other variant.

icon

An optional Phosphor icon name overriding the variant default.

alert-classes

List of symbols representing container CSS classes.

(alert #:title "Heads up" #:body "Your session expires soon." #:variant 'warning)
Procedure: circular-progress KEY: #:value #:max #:size #:label #:show-value #:stroke-width #:classes

Create a circular progress ring.

The ring is an SVG with a normalised pathLength of 100, so the fraction is written as a dash of that length and the browser does the geometry; no trigonometric value has to be computed in Scheme. With no value the ring is indeterminate: it spins through CSS and the accessible value is left out, which is what tells assistive technology that the work has no known end.

value

The current value, or #f for an indeterminate ring.

max

The maximum value. Defaults to 100.

size

'xs, 'sm, 'md, 'lg or 'xl.

label

An accessible name for the ring.

show-value

Whether the percentage is written in the middle. Defaults to false.

stroke-width

The ring’s stroke width in the SVG’s own units. Defaults to 4.

classes

Extra classes for the wrapper.

(circular-progress #:value 68 #:label "Importing" #:show-value #t)
Procedure: empty-state KEY: #:icon #:title #:body #:action #:classes

Create the first-class empty state a data component falls back to.

An empty list is not an error and should not look like one: the icon is a quiet object, the copy says what is missing and, when there is one, the action says what to do about it. Assistive technology gets the heading it needs to understand the region, because the title is a real <h3>.

icon

The Phosphor icon name. Defaults to 'tray.

title

The heading that names the state.

body

Optional explanatory copy.

action

An optional node – usually a link or a button – offering the next step.

classes

Extra classes for the wrapper.

(empty-state #:title "No projects yet"
             #:body "Create one to get started."
             #:action (primary-button "New project"))
Procedure: error-state KEY: #:title #:body #:retry #:retry-label #:details #:classes

Create the error state a data component shows when a request failed.

It is an empty state with a different voice – a warning mark, a danger ink, and a retry action – because "there is nothing here" and "this did not load" call for different responses from the reader. The retry is just a link or a button the page passes, so it works with a normal navigation and no client-side store has to be asked to try again.

title

The heading. Defaults to a generic failure sentence.

body

The explanation. Defaults to a generic one.

retry

An optional retry node, usually a link back to the same URL.

retry-label

The text of the default retry link, used when no retry node is given.

details

Optional technical detail, folded away in a disclosure.

classes

Extra classes for the wrapper.

(error-state #:retry (a "Try again" #:href "/reports"))
Procedure: progress KEY: #:value #:max #:label #:show-value #:progress-classes #:bar-classes

Create a native HTML <progress> bar.

value

The current value. When omitted the bar renders in an indeterminate state.

max

The maximum value. Defaults to 100.

label

An optional text label shown above the bar and used for accessibility.

show-value

A boolean rendering the percentage next to the label.

progress-classes

List of symbols representing the progress bar CSS classes.

bar-classes

List of additional utility CSS classes.

(progress #:value 42 #:label "Uploading" #:show-value #t)
Procedure: skeleton KEY: #:lines #:height #:rounded #:classes

Create a pulsing placeholder shown while content loads.

lines

The number of placeholder rows to render.

height

A height keyword: 'sm, 'md or 'lg.

rounded

A rounding keyword: 'none, 'sm, 'md or 'full.

classes

List of additional utility CSS classes.

(skeleton #:lines 3 #:height 'md)
Procedure: skeleton-avatar KEY: #:size #:classes

A placeholder for an avatar.

size

'sm, 'md or 'lg.

classes

Extra classes.

(skeleton-avatar #:size 'lg)
Procedure: skeleton-card KEY: #:lines #:avatar? #:classes

A placeholder for a card: a header row and a few lines of copy.

lines

How many body lines to draw.

avatar?

Whether the header carries an avatar placeholder.

classes

Extra classes.

(skeleton-card #:lines 2 #:avatar? #t)
Procedure: skeleton-form KEY: #:fields #:classes

A placeholder for a form: one field block per control.

fields

How many field blocks to draw.

classes

Extra classes.

(skeleton-form #:fields 4)
Procedure: skeleton-heading KEY: #:width #:classes

A placeholder for a heading line.

width

A width utility list. Defaults to (w-1/2).

classes

Extra classes.

(skeleton-heading #:width '(w-1/3))
Procedure: skeleton-table KEY: #:rows #:columns #:classes

A placeholder for a data table: a header rule and the requested rows.

rows

How many body rows to draw.

columns

How many cells per row.

classes

Extra classes.

(skeleton-table #:rows 5 #:columns 3)
Procedure: skeleton-text KEY: #:lines #:last-width #:classes

A placeholder for a paragraph, one block per line.

The last line is shorter, which is what makes the block read as text rather than as a table. The whole placeholder is hidden from assistive technology; the loading state is announced once by whatever region owns it.

lines

How many lines to draw.

last-width

The width of the final line. Defaults to (w-2/3).

classes

Extra classes.

(skeleton-text #:lines 4)
Procedure: spinner KEY: #:size #:label #:classes

Create an accessible CSS loading spinner.

The spinner animates through CSS only and exposes a screen-reader label through role="status", so it works without JavaScript.

size

A size keyword: 'xs, 'sm, 'md, 'lg or 'xl.

label

The screen-reader status text. Defaults to "Loading...".

classes

List of additional utility CSS classes.

(spinner #:size 'lg #:label "Fetching results")
Procedure: toast KEY: #:title #:body #:variant #:duration #:dismissible? #:dismiss-label #:id #:classes

Create one toast: a small frosted card that arrives, says one thing, and can leave again.

The toast is a live region of its own – status for a quiet variant and alert for a danger – so a screen reader announces it without the page having to move focus. The dismiss control is a progressive enhancement (js-only); a toast rendered by the server is still readable and still carries its text, and the script that queues toasts is what makes it leave on its own.

Toast markup is also the template toast-tray clones, which is why the title and body carry data-hg-toast-title and data-hg-toast-body: one shape serves both the server-rendered case and the queued one.

title

The toast’s heading.

body

Optional supporting copy.

variant

'info (default), 'success, 'warning or 'danger.

duration

How long the toast stays, in milliseconds. Defaults to 5000; the script reads it from the markup.

dismissible?

Whether the dismiss control is rendered. Defaults to true.

dismiss-label

The accessible name of the dismiss control.

id

An optional identifier.

classes

Extra classes for the card.

(toast #:title "Saved" #:body "Your changes are live." #:variant 'success)
Procedure: toast-tray KEY: #:id #:label #:max #:position #:template-id #:classes

Create the live region a page’s toasts arrive in, and its template.

The tray is one polite region, never one region per toast: a screen reader announces an addition once, and the page keeps a single place where its notifications live. The template inside it is a toast with empty slots; the queue script clones it, fills the slots with textContent, appends the clone, and removes it after its duration. Nothing a notification says is ever parsed as markup, so a title cannot smuggle an element into the page.

id

The tray’s identifier.

label

Its accessible name.

max

How many toasts the tray keeps at once, oldest first.

position

'bottom-end (default), 'bottom-start, 'top-end or 'top-start.

template-id

The identifier of the template the script clones.

classes

Extra classes for the tray.

(toast-tray)

Next: (hygguile components field), Previous: (hygguile components disclosure), Up: API