Navigation drawer¶
Navigation
In Material Design 3¶
A navigation drawer holds more destinations than a rail, as a vertical list of icon-and-label items. It can be permanent (standard) or slide over the content (modal).
In Tesserae¶
Views Tesserae ships: NavigationDrawer (standard, beside the content), NavigationDrawerModal (over a scrim), NavigationDrawerScreens (the app's screens), and
NavigationDrawerItem (one destination) and NavigationDrawerPanel (the inside the first two share).
The Items are rows: {Value, Label, Icon} and optionally {Badge, Disabled}, {heading: Text} for a section's title, and {divider: true} for a line (for
NavigationDrawerScreens, {Screen, Label, Icon} in place of Value). Selected is the chosen destination, and a press or an arrow key writes it back. Open is two-way: on a
standard drawer it says whether the drawer takes its room (the width eases, which is how it collapses), on a modal one whether it is showing. The drawer is Width wide, held between
256 and 360 pixels (360 by default). Frosted: true makes the surface translucent and blurred.
A destination is a 56 pixel pill with 28 pixel corners, a 24 pixel icon, a label_large label and a badge at the end; the chosen one is secondary_container.
Children with Slot: header and Slot: footer go above and below the destinations, which scroll when there are too many. A modal drawer is
surface_container_low at level 1 with 16 pixel corners on the right; a press on a destination closes it, as do Escape and a press on the scrim. A screen reader hears
a link per destination, the current one marked as the page. Not built: the modal drawer sliding in (an overlay is where its style says when first drawn), and a
standard drawer that becomes a rail by itself when the window narrows.
How it is built¶
A view Tesserae ships is a <Name>_View.tdl (what it takes and what it is made of) with a <Name>_Stylesheet.tdl (how it looks). Use it by name: NavigationDrawer { ... }. A file of the same name in your project replaces it.
NavigationDrawer¶
The Material 3 standard navigation drawer: a permanent column of destinations beside the content, 360 pixels wide (256 to 360), a surface column. While Open it takes its width from the content and when it is closed it takes none (the width eases): that is how it collapses, and a rail can take its place. Children with Slot: header and Slot: footer go above and below the destinations. See NavigationDrawerPanel for the items and the keyboard.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
Frosted |
bool |
false |
A translucent surface that blurs what is behind it (72% of its colour, a 20 pixel backdrop blur). |
Open |
bool |
true |
Whether the drawer takes its room. Two-way: give it a bare reference and the view writes it back. |
Items |
list |
[] |
The rows: {value, label, icon} and optionally {badge, disabled}; {heading: Text}; {divider: true}. |
Selected |
any |
The value of the chosen destination. Two-way: give it a bare reference and the view writes it back. | |
Width |
float |
360 |
From 256 to 360 pixels. |
Children go in the header slot, the footer slot.
Its parts, by name (a stylesheet rule's Part or Name addresses one): panel (NavigationDrawerPanel).
Its look is in NavigationDrawer_Stylesheet.tdl.
NavigationDrawerItem¶
One destination of a navigation drawer (Material 3): a 56 pixel tall pill with a 24 pixel icon, a label_large label and, at the end, a badge (a count or short text). The selected one is secondary_container. A screen reader hears a link named by the label, current when it is selected. Handlers: {On_Click: ...} on the call is what a press does.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
Label |
str |
The destination's name. | |
Icon |
str |
The icon. | |
Badge |
any |
A count or short text at the end; empty for none. | |
Selected |
bool |
false |
Whether this is where the user is. |
Disabled |
bool |
false |
Dimmed and not pressable. |
Its parts, by name (a stylesheet rule's Part or Name addresses one): icon (Icon), label (Text), filler (Container), badge (Text).
Its look is in NavigationDrawerItem_Stylesheet.tdl.
NavigationDrawerModal¶
The Material 3 modal navigation drawer: the same destinations, over the content on a scrim from the start edge, surface_container_low at level 1 with 16 pixel corners on the side that opens. Pressing a destination closes it (and writes the choice); Escape and a press on the scrim close it too, writing false to Open, and focus goes back to where it was. A menu button in the calling view opens it by writing Open.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
Frosted |
bool |
false |
A translucent surface that blurs what is behind it (72% of its colour, a 20 pixel backdrop blur). |
Open |
bool |
false |
Whether the drawer is showing. Two-way: give it a bare reference and the view writes it back. |
Items |
list |
[] |
The rows: {value, label, icon} and optionally {badge, disabled}; {heading: Text}; {divider: true}. |
Selected |
any |
The value of the chosen destination. Two-way: give it a bare reference and the view writes it back. | |
Width |
float |
360 |
From 256 to 360 pixels. |
Children go in the header slot, the footer slot.
Its parts, by name (a stylesheet rule's Part or Name addresses one): sheet (Container), panel (NavigationDrawerPanel).
Its look is in NavigationDrawerModal_Stylesheet.tdl.
NavigationDrawerPanel¶
The inside of a navigation drawer, which NavigationDrawer (standard) and NavigationDrawerModal both put in a sheet: a header slot, the destinations in a column that scrolls when there are more than fit, and a footer slot. Items is a list of {value, label, icon} and optionally {badge, disabled}; a {heading: Text} is a section's title and a {divider: true} a line. Selected is the value of the chosen one and a press writes it back. One Tab stop on the current destination; the up and down arrows move the focus and choose it.
| Parameter | Type | Default | Meaning |
|---|---|---|---|
Items |
list |
[] |
The rows: {value, label, icon} and optionally {badge, disabled}; {heading: Text}; {divider: true}. |
Selected |
any |
The value of the chosen destination. Two-way: give it a bare reference and the view writes it back. | |
On_Pick |
handler |
Called after a destination has been pressed (a modal drawer closes itself with it). | |
Width |
float |
360 |
From 256 to 360 pixels. |
Children go in the header slot, the footer slot.
Its parts, by name (a stylesheet rule's Part or Name addresses one): list (ScrollView), row (Container), divider (Divider), heading (Text), item (NavigationDrawerItem).
Its look is in NavigationDrawerPanel_Stylesheet.tdl.
NavigationDrawerScreens¶
A standard navigation drawer whose destinations are the app's screens: Items is a list of {screen, label, icon} and optionally {badge}, with {heading: Text} and {divider: true} rows between them. The destination of the screen showing is selected, and pressing one navigates to its screen. It belongs in each screen (or in a window's shell).
| Parameter | Type | Default | Meaning |
|---|---|---|---|
Items |
list |
[] |
The rows: {screen, label, icon} and optionally {badge}; {heading: Text}; {divider: true}. |
Width |
float |
360 |
From 256 to 360 pixels. |
Its parts, by name (a stylesheet rule's Part or Name addresses one): row (Container), divider (Divider), heading (Text), item (NavigationDrawerItem).
Its look is in NavigationDrawerScreens_Stylesheet.tdl.
Using it¶
Container {
Name: shell
Style { Flex_Direction: horizontal, Width: 720, Height: 480 }
Children {
NavigationDrawer {
Selected: <| page |>
Items {
Item { Value: inbox, Label: Inbox, Icon: home, Badge: 24 }
Item { Value: sent, Label: Sent, Icon: send }
Item { Divider: true }
Item { Heading: Labels }
Item { Value: work, Label: Work, Icon: tag }
}
}
NavigationDrawerScreens {
Items {
Item { Screen: Main, Label: Tasks, Icon: home }
Item { Screen: Settings, Label: Settings, Icon: cog }
}
}
}
}
Using it in Python¶
from tess_ui.widgets import navigation_drawer
drawer = navigation_drawer(app.window, ["Inbox", "Search"], ["home", "search"], selected=0)
Changing its look¶
To restyle it in your whole app, write rules for it in your app's stylesheet, or put <Name>_Stylesheet.tdl next to your views (or in Styles/); it is read only while the app uses the view. A rule names the widget and may narrow it by the properties it declares, a part and a state; the most specific rule wins, and a node's own Style beats every rule:
# NavigationDrawer_Stylesheet.tdl, or any stylesheet your app loads
Styles {
Rule {
Widget: NavigationDrawer
Style { Background: tertiary }
}
}