Next: , Previous: , Up: API  


1.18 (hygguile components navigation)

1.18.1 Procedures

Procedure: breadcrumbs KEY: #:items #:separator #:nav-class #:list-class

Create an accessible breadcrumb trail from a list of nodes.

The trail is rendered as a <nav> with an ordered list, and the final item is marked with aria-current="page". Breadcrumbs are static markup and work without JavaScript.

items

An ordered list of link or text nodes, from root to current page.

separator

The string shown between items. Defaults to "/".

nav-class

List of symbols representing the nav wrapper CSS classes.

list-class

List of symbols representing the list CSS classes.

(breadcrumbs #:items (list (a "Home" #:href "/") (a "Docs" #:href "/docs") (span "API")))

Create a navigation link with an optional active state.

When active is true, the link also carries aria-current="page" so assistive technology announces the current section. Links never require JavaScript.

content

The link label.

href

The destination URL.

active

A boolean marking this link as the current page.

classes

List of base link CSS classes.

active-classes

List of symbols applied when the link is active.

inactive-classes

List of symbols applied when the link is inactive.

(nav-link "Pricing" #:href "/pricing")
Procedure: nav-rail KEY: #:items #:label #:current #:classes

Create a narrow icon rail for a primary navigation.

Each item is a triple, (icon label href): the icon is what is drawn, and the label is what assistive technology reads and what a mouse reader sees in the browser’s own tooltip. A rail is the right shape for a desktop application with a persistent set of destinations and no room for words; the labels are still there in the markup, which is what keeps it usable.

items

A list of (icon label href) triples.

label

The accessible name of the navigation region.

current

The href of the current page.

classes

Extra classes for the rail.

(nav-rail #:items '((house "Home" "/") (gear "Settings" "/settings")))
Procedure: navbar content KEY: #:brand #:sticky #:navbar-classes

Create a top navigation bar shell.

The bar is a frosted glass surface like every other one in the framework: it is built by glass-panel, which owns the frost (the translucent tint and the backdrop blur), so the tint in navbar-classes is not the bar’s to invent. What the bar owns is its silhouette – it spans the viewport, so it has no rounding, no border and no padding of the panel’s own, and its layout lives in navbar-classes.

content

The navigation content, typically a list of nav-link elements.

brand

An optional brand/logo node shown at the start of the bar.

sticky

A boolean pinning the bar to the top of the viewport. Defaults to true.

navbar-classes

List of symbols representing the bar’s layout and place. A colour utility among them replaces the panel’s tint, so a bar can recolour its own glass.

(navbar (list (nav-link "Home" #:href "/" #:active #t)) #:brand "Hygguile")
Procedure: pagination KEY: #:current #:total #:base-url #:prev-label #:next-label #:nav-class #:link-class #:active-class

Create page navigation for a paginated result set.

current

The current page number, starting at 1.

total

The total number of pages.

base-url

The URL prefix each page number is appended to. Defaults to "#".

prev-label

The label for the previous-page link.

next-label

The label for the next-page link.

nav-class

List of symbols representing the nav wrapper CSS classes.

link-class

List of symbols representing a page link’s base CSS classes.

active-class

List of symbols highlighting the current page link.

(pagination #:current 2 #:total 5 #:base-url "/blog?page=")
Procedure: section-nav sections KEY: #:label #:sticky? #:scroll-spy? #:classes #:list-classes #:link-classes #:active-classes #:inactive-classes

Create a rail of links to the sections of one page.

A page whose sections are stacked one under another is hard to move around in, and a table of contents that scrolls away is no help once a reader is past it. This rail is that list of links, frosted so it holds its own over whatever it passes, and sticky from the small breakpoint up: any section stays one tap away, and each link is an ordinary anchor, so it works with JavaScript disabled and can be bookmarked or shared.

sections

A list of (id . label) pairs, in the order the rail should show them. Each id is the identifier of the section it points at.

label

The accessible name of the rail, read out by assistive technology.

sticky?

Whether the rail follows the page from the small breakpoint up.

scroll-spy?

Whether the rail marks the section a reader is currently in. The marking is done by the framework’s scroll-spy script (a progressive enhancement), and the attribute it needs is written only when the page asks for it. Defaults to true.

classes

List of base CSS classes for the <nav>.

list-classes

List of CSS classes for the wrapping <ul>.

link-classes

List of CSS classes for every link.

active-classes

List of CSS classes applied to the link of the current section.

inactive-classes

List of CSS classes applied to the other links.

(section-nav '((buttons . "Buttons") (forms . "Forms")))
Procedure: sidebar KEY: #:brand #:sections #:footer #:label #:current #:sticky? #:classes

Create a vertical navigation sidebar, collapsing to a plain list on phones.

A sidebar is a page’s own table of contents for an application: a brand at the top, one or more groups of links, and an optional footer (usually a settings link or an account block). It is a real <nav> with a label, each link is an ordinary anchor, and the current page is marked with aria-current. From the large breakpoint up it can stick beside the content; below it, it is simply a list above the page.

brand

An optional node shown at the top.

sections

A list of (heading . items) pairs. Each item is either a (label . href) pair or a node built with sidebar-link.

footer

An optional node shown at the bottom.

label

The accessible name of the navigation region.

current

The href of the current page, used to mark the active link.

sticky?

Whether the sidebar sticks from the large breakpoint up.

classes

Extra classes for the sidebar.

(sidebar #:brand "LucidPlan"
         #:current "/projects"
         #:sections '(("Work" ("Projects" . "/projects")
                               ("Reports" . "/reports"))
                      ("Account" ("Settings" . "/settings"))))

Create one link of a sidebar, with an optional icon and badge.

The link marks the page it is on with aria-current="page", so a screen reader announces the current item the same way the stylesheet paints it.

label

The link text.

href

The destination.

icon

An optional Phosphor icon name shown before the label.

active

Whether this is the current page.

badge

An optional short count or label shown at the end of the row.

classes

Extra classes for the link.

(sidebar-link "Settings" #:href "/settings" #:icon 'gear)
Procedure: tab KEY: #:id #:label #:content

Describe a single tab for use with tabs.

id

A short, group-unique identifier used to bind the tab, its label and its panel.

label

The visible label shown on the tab button.

content

The panel content fragments.

(tab #:id "billing" #:label "Billing" #:content (list (p "Invoices")))
Procedure: tabs KEY: #:tab-items #:id #:selected #:tabs-class

Create a JavaScript-free tabbed interface.

Each tab is a hidden radio input paired with a visible label; selecting a label reveals the matching panel purely through CSS (:checked and :has). This means the component remains fully functional with JavaScript disabled and is keyboard accessible, since the underlying controls are native form elements.

tab-items

A list of tab descriptors.

id

An optional group identifier; a unique one is generated when omitted.

selected

The id of the tab selected initially. Defaults to the first tab.

tabs-class

List of symbols representing the wrapper CSS classes.

(tabs #:tab-items (list (tab #:id "a" #:label "A" #:content (list (p "A")))
                       (tab #:id "b" #:label "B" #:content (list (p "B")))))
Procedure: wizard KEY: #:steps #:current #:label #:orientation #:numbered? #:classes

Create the ordered steps of a multi-step form or a checkout.

The list is a real <ol>, because the order is the point, and the step the reader is on carries aria-current="step". Steps before it are marked complete, steps after it are marked upcoming, and every step that has an href is a link so a reader can go back. Nothing here needs a script: the server knows which step it rendered, and that is the state the page shows.

steps

A list of steps, each a label string or a (label . href) pair.

current

The 1-based index of the current step, or its label.

label

The accessible name of the navigation region.

orientation

'horizontal (default) or 'vertical.

numbered?

Whether each step shows its number (or a check when complete).

classes

Extra classes for the wrapper.

(wizard #:steps '(("Cart" . "/cart") ("Address") ("Payment"))
        #:current 2)

Next: (hygguile components notification), Previous: (hygguile components media), Up: API