Skip to content

Navigation

nav is a block of the app block. It names the pages of the menu, in menu order.

app sports_club "Sampletown Sports Club" {
nav main "Club" {
dashboard
members
events
}
nav public "Public" {
public_events
}
}

An entry is the name of a page. The compiler resolves it; an unknown page is a compile error.

nav <name> "<Label>" {
<page> ["<Label>"]
group <name> "<Label>" {
<page> ["<Label>"]
…
}
…
}
Part Effect
<name> identifies the block. It is not shown.
"<Label>" the group’s label. Shown on a desktop as the menu group, on a phone as the section heading.
<page> a page declared in this application.
["<Label>"] overrides the entry’s text. Without it, the entry shows the page’s label, then the page’s name.
[icon <name>] draws an icon before the entry’s text. See icon.
group a labelled list of pages inside this menu. See group.

An application can declare more than one nav block. The blocks keep the order you wrote them in.

Write icon <name> after the label of a page entry to draw an icon before its text.

nav main "Club" {
dashboard "Overview" icon layout_dashboard
members icon users
}

The name must be one of the icons. An unknown name is a compile error at the name, and the message lists the valid names. The icon has the colour of the text. A menu entry always shows its text, so only is a compile error here. A group heading and the label of a nav block take no icon.

A group puts some pages of a menu under their own label. Write it inside a nav block, between the pages, where it must appear.

nav admin "Administration" {
users
group billing "Billing" {
invoices
plans
}
audit_log
}
Part Effect
<name> identifies the group. It is not shown.
"<Label>" the label over the group’s pages. Without it, the name is shown.
<page> ["<Label>"] the same as a page entry of a nav block.

A group is one level deep. It holds pages only, and it can only be written directly in a nav block.

On a desktop the group is a labelled list inside its menu’s panel, with a line above it. It does not open a second panel. On a phone it is the same list, indented, inside the full-screen menu. When the current page is in a group, the menu that holds the group is marked as current.

In the single row of links for five links or fewer, a group’s label is not shown, like the labels of the nav blocks. Its pages appear in their place in the row.

A page can be called group. The word starts a group only when a name follows it, so an entry group alone on its line, or with only a label, is that page.

The engine chooses the shape from the number of links this reader may open, not from what you declared. Two readers of the same application can therefore get two shapes.

Links the reader may open Shape
5 or fewer one row of links. Group labels are not shown.
more than 5 one menu per group. The group opens when the reader points at it or moves the keyboard to it.

Below 48rem (768px) the second shape becomes a full-screen menu behind a ☰ button. Every group is open inside it, so no entry is more than one scroll away.

Three details you do not declare and cannot turn off:

  • A group label is a link. It goes to the first entry of that group the reader may open.
  • A group with one entry the reader may open is drawn as that entry. There is no menu over a single link.
  • The group holding the current page is marked, so the reader sees where they are without opening anything.

None of this needs JavaScript. A small script adds keyboard and screen-reader refinements when it loads, and the menu works the same way when it does not.

An entry the reader may not open is absent

Section titled “An entry the reader may not open is absent”

The engine asks the same access rule the page itself is guarded by. A reader who may not open a page never sees its link.

nav portal "Portal" {
eltern // guardians only
mein // teachers only
}

A teacher gets one entry here, a guardian gets the other, and neither is told the other exists. A menu where the reader may open nothing is left out entirely, label and all. The same applies to a group: when the reader may open none of its pages, its label is not shown. A menu that holds only such groups is left out.

So a menu is not a second access rule. You do not repeat your access rules in nav, and you cannot widen them there.

The application name in the header is a link. It goes to the first of these that exists:

  1. The application’s front page: the page with route: /, when the reader may open it. A signed-in reader goes there too, even when the first entry of their menu is another page. The page may be public or restricted to some roles. The address stays inside the application’s mount, and in the reader’s language for a multilingual application. The front page does not have to be in a nav.
  2. The first entry of the reader’s menu, after the access rules have removed what they may not open.
  3. The root of the application, when the reader’s menu is empty.

A page with route: / that the reader may not open is skipped. The name then links to the first menu entry, as in rule 2, so the name never links to a page that refuses the reader. The engine also uses this address after a row is deleted.

Case What happens
an unknown page name, in a nav block or in a group compile error
a page whose route: carries a parameter, such as /members/{id} the entry is skipped. A menu entry is an address, and a pattern is not one.
the same page listed twice, in two menus or in a menu and a group it appears once, in its first position
a group inside a group compile error
a group with no page compile error
a group directly in the app block compile error
two nav blocks or groups with the same name compile error. nav and group names share one namespace in an application.
  • A menu has two levels: the nav block and a group inside it. A group cannot hold a group.
  • Every page you want in a menu must be listed. A page that is in no nav block is still reachable by its address and by a link from a row.

Website privacy policy