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>"]
…
}
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.

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

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 group where the reader may open nothing is left out entirely, label and all.

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

Case What happens
an unknown page name 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 it appears once, in its first position
  • nav is one level deep. 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.

See Project status for nested navigation.