Overlays and menus
Some parts of a page appear only when asked: a dialog, a menu, a hint. This lesson shows every such component of the design system, with its elements, attributes, values and a live example you can click.
Panels that stay on the page
Overlays are drawn above the page or hide part of it until asked. Behaviour (keyboard, focus, ARIA, events) does not depend on the design: with design = with they still work (only the look is dropped). Every example below is live. Where something opens, press the button, hover or click as the text says.design = "none" they still workquot;nonewith design = "none" they still workquot;
tabs (Persian: زبانه ها)
Tabs show one panel at a time. The tabs root holds a tab list of tab trigger buttons and one tab content per trigger; the value of a trigger and its content must match, and default value picks the open one. The arrow keys (aware of right to left text), Home and End move and select. The example shows the default list, the line list variant and vertical tabs.
page:
box:
layout = "column"
gap = 16
width = 360
tabs:
default value = "account"
tab list:
tab trigger:
value = "account"
content = "Account"
end
tab trigger:
value = "password"
content = "Password"
end
tab trigger:
value = "off"
content = "Off"
disabled = true
end
end
tab content:
value = "account"
paragraph:
content = "Change your name and email here."
end
end
tab content:
value = "password"
paragraph:
content = "Pick a new password."
end
end
end
tabs:
default value = "one"
tab list:
variant = "line"
tab trigger:
value = "one"
content = "Overview"
end
tab trigger:
value = "two"
content = "Activity"
end
end
tab content:
value = "one"
paragraph:
content = "The line variant draws an underline."
end
end
tab content:
value = "two"
paragraph:
content = "Recent events show up here."
end
end
end
tabs:
orientation = "vertical"
default value = "a"
tab list:
tab trigger:
value = "a"
content = "General"
end
tab trigger:
value = "b"
content = "Billing"
end
end
tab content:
value = "a"
paragraph:
content = "Vertical tabs sit side by side."
end
end
tab content:
value = "b"
paragraph:
content = "Invoices and plans."
end
end
end
end
end| Element | Attributes | Values or notes |
|---|---|---|
tabs | default value, orientation | horizontal, vertical |
tab list | variant | default, line |
tab trigger | value, disabled, content | the key and the label |
tab content | value | which trigger it belongs to |
accordion (Persian: آکاردئون)
An accordion is a stack of sections that open and close. Each accordion item holds an accordion trigger and an accordion content. With type = "single" opening one closes the others; collapsible = true lets the open one be closed again; type = "multiple" keeps several open. Put open = true on an item to start open. Opening and closing animate for 200 ms unless the visitor asked for reduced motion.
page:
box:
layout = "column"
gap = 24
width = 400
accordion:
type = "single"
collapsible = true
accordion item:
value = "a"
open = true
accordion trigger:
content = "Is it accessible?"
end
accordion content:
content = "Yes. It follows the WAI-ARIA pattern and works with the keyboard."
end
end
accordion item:
value = "b"
accordion trigger:
content = "Is it styled?"
end
accordion content:
content = "Yes. It comes with the design of the page."
end
end
accordion item:
value = "c"
accordion trigger:
content = "Is it locked?"
disabled = true
end
accordion content:
content = "Not shown."
end
end
end
accordion:
type = "multiple"
accordion item:
value = "x"
accordion trigger:
content = "First"
end
accordion content:
content = "With multiple, several items can be open."
end
end
accordion item:
value = "y"
accordion trigger:
content = "Second"
end
accordion content:
content = "Open this one too."
end
end
end
end
end| Element | Attributes | Values or notes |
|---|---|---|
accordion | type, collapsible, default value | single, multiple |
accordion item | value, open | start open |
accordion trigger | disabled, content | the heading button |
accordion content | content | the hidden text |
collapsible (Persian: جمع شونده)
A collapsible is one section that shows and hides its content, like a single accordion item. Use open = true to start open.
page:
collapsible:
width = 320
box:
layout = "row"
gap = 8
paragraph:
content = "3 repositories starred"
end
collapsible trigger:
content = "Toggle"
end
end
collapsible content:
content = "salam, std, website"
end
end
end| Element | Attributes | Values or notes |
|---|---|---|
collapsible | open | start open |
collapsible trigger | disabled, content | the toggle button |
collapsible content | content | the hidden part |
Dialogs, sheets and drawers
dialog (Persian: پنجره گفتگو)
A dialog is a modal window over the page. It is a native dialog opened with showModal, so focus stays inside, the page behind is inert, Escape closes it and focus returns to the button. Give it an id and set opens to that id on a button or a dialog trigger. Close it with closes = true on a button, with a dialog close element, or with the corner X (turn that off with show close = false). A click outside the window also closes it; write close outside = false to turn that off so that only the buttons and Escape close it. width sets the size. Press the buttons in the example to open them. Inside, dialog header holds the dialog title and dialog description, and dialog footer holds the buttons; the example uses all four.
page:
dialog trigger:
opens = "edit"
content = "Edit profile"
end
dialog:
id = "edit"
dialog header:
dialog title:
content = "Edit profile"
end
dialog description:
content = "Change your public name. Press Escape to close."
end
end
dialog footer:
dialog close:
content = "Cancel"
end
button:
closes = true
content = "Save"
end
end
end
dialog:
id = "plain"
show close = false
width = 280
dialog title:
content = "No corner X"
end
dialog footer:
dialog close:
content = "Got it"
end
end
end
button:
variant = "secondary"
opens = "plain"
content = "Small, no X"
end
end| Element | Attributes | Values or notes |
|---|---|---|
dialog | id, show close, close outside, width, open | true, false for the X; close outside is true unless you write false |
dialog header, title, description, footer | content | the usual parts |
dialog trigger | opens | the id to open |
dialog close | variant, size | button values, default outline |
By default a click on the dark area outside a window closes it, for the dialog, the alert dialog, the sheet and the drawer. Write close outside = false on the window when only its buttons and Escape should close it, for example a form that must not be lost by a stray click. The first button below uses the default and the second turns it off.
page:
box:
layout = "row"
gap = 8
button:
opens = "auto"
content = "Closes on outside click"
end
button:
variant = "outline"
opens = "locked"
content = "Stays open"
end
end
dialog:
id = "auto"
dialog title:
content = "Click outside me"
end
dialog description:
content = "A click on the dark area closes this window. This is the default."
end
end
dialog:
id = "locked"
close outside = false
dialog title:
content = "Outside clicks are ignored"
end
dialog description:
content = "Only the corner X, the button and Escape close this window."
end
dialog footer:
dialog close:
content = "Close"
end
end
end
endalert dialog (Persian: پنجره هشدار)
An alert dialog asks for a decision before something that cannot be undone. It has no corner X, and the visitor normally picks alert dialog cancel or alert dialog action. size = "sm" makes the small form. Open it with the buttons below. The question goes in alert dialog header as an alert dialog title and an alert dialog description, and the two choices go in alert dialog footer. It also closes on an outside click, like the other windows; write close outside = false when the visitor has to choose a button.
page:
box:
layout = "row"
gap = 8
button:
variant = "destructive"
opens = "del"
content = "Delete account"
end
button:
variant = "outline"
opens = "small"
content = "Small size"
end
end
alert dialog:
id = "del"
alert dialog header:
alert dialog title:
content = "Are you sure?"
end
alert dialog description:
content = "This cannot be undone. Clicking outside does not close it."
end
end
alert dialog footer:
alert dialog cancel:
content = "Cancel"
end
alert dialog action:
variant = "destructive"
content = "Delete"
end
end
end
alert dialog:
id = "small"
size = "sm"
alert dialog header:
alert dialog media:
span:
content = "!"
end
end
alert dialog title:
content = "Leave page?"
end
alert dialog description:
content = "Unsaved changes are lost."
end
end
alert dialog footer:
alert dialog cancel:
content = "Stay"
end
alert dialog action:
content = "Leave"
end
end
end
end| Element | Attributes | Values or notes |
|---|---|---|
alert dialog | id, size | default, sm |
alert dialog header, title, description, footer, media | content | the usual parts |
alert dialog action | variant, size | button values |
alert dialog cancel | variant, size | button values, default outline |
sheet (Persian: برگه کناری)
A sheet is a dialog that slides in from an edge of the screen, for settings or a menu. side picks the edge: top, right (the default), bottom or left. It opens and closes like a dialog. The example has one button for each side; the left one has no corner X. Each sheet in the example is built from a sheet header with a sheet title and sheet description, and a sheet footer for the actions. A click outside closes it unless you write close outside = false.
page:
box:
layout = "row"
gap = 8
button:
variant = "outline"
opens = "s-top"
content = "Top"
end
button:
variant = "outline"
opens = "s-right"
content = "Right"
end
button:
variant = "outline"
opens = "s-bottom"
content = "Bottom"
end
button:
variant = "outline"
opens = "s-left"
content = "Left"
end
end
sheet:
id = "s-top"
side = "top"
sheet header:
sheet title:
content = "Top sheet"
end
sheet description:
content = "Slides down from the top edge."
end
end
end
sheet:
id = "s-right"
side = "right"
sheet header:
sheet title:
content = "Right sheet"
end
sheet description:
content = "The default side. Edit settings here."
end
end
sheet footer:
button:
closes = true
content = "Save"
end
end
end
sheet:
id = "s-bottom"
side = "bottom"
sheet header:
sheet title:
content = "Bottom sheet"
end
sheet description:
content = "Slides up from the bottom edge."
end
end
end
sheet:
id = "s-left"
side = "left"
show close = false
sheet header:
sheet title:
content = "Left sheet"
end
sheet description:
content = "No corner X here; use Escape or the button."
end
end
sheet footer:
button:
variant = "outline"
closes = true
content = "Close"
end
end
end
endFor a page that is read in both directions use start and end instead of left and right. start is the left edge in a left to right page and the right edge in a right to left page; end is the opposite one. Both the sheet and the drawer take them, and the slide animation and the drawer's drag to dismiss follow the direction too.
page:
box:
layout = "row"
gap = 8
button:
variant = "outline"
opens = "s-start"
content = "Start"
end
button:
variant = "outline"
opens = "s-end"
content = "End"
end
button:
variant = "outline"
opens = "d-start"
content = "Drawer at start"
end
end
sheet:
id = "s-start"
side = "start"
sheet header:
sheet title:
content = "Start sheet"
end
sheet description:
content = "Left in a left to right page, right in a right to left page."
end
end
end
sheet:
id = "s-end"
side = "end"
sheet header:
sheet title:
content = "End sheet"
end
sheet description:
content = "The opposite edge, so it follows the reading direction too."
end
end
end
drawer:
id = "d-start"
side = "start"
drawer header:
drawer title:
content = "Drawer"
end
drawer description:
content = "Drag it toward its edge to dismiss it."
end
end
end
end| Element | Attributes | Values or notes |
|---|---|---|
sheet | side, show close, id | top, right, bottom, left, start, end |
sheet header, title, description, footer | content | the usual parts |
drawer (Persian: کشو)
A drawer is a sheet made for touch: by default it rises from the bottom with a handle, and dragging it down dismisses it. side moves it to another edge. Its content uses the same drawer header, drawer title, drawer description and drawer footer as a sheet. A click outside closes it unless you write close outside = false.
page:
box:
layout = "row"
gap = 8
button:
variant = "outline"
opens = "dr"
content = "Open drawer"
end
button:
variant = "outline"
opens = "dr-right"
content = "Side drawer"
end
end
drawer:
id = "dr"
drawer header:
drawer title:
content = "Move goal"
end
drawer description:
content = "Drag the handle down to dismiss."
end
end
drawer footer:
button:
closes = true
content = "Submit"
end
button:
variant = "outline"
closes = true
content = "Cancel"
end
end
end
drawer:
id = "dr-right"
side = "right"
drawer header:
drawer title:
content = "Side drawer"
end
drawer description:
content = "The side attribute moves the drawer."
end
end
end
end| Element | Attributes | Values or notes |
|---|---|---|
drawer | side, id | default bottom |
drawer header, title, description, footer | content | the usual parts |
Popovers and tooltips
popover (Persian: پنجره شناور)
A popover is a small panel next to its trigger, for a bit of extra content or a mini form. The root holds a popover trigger and a popover content. A trigger with no children draws an outline button from its content; put your own button inside to use another. On the content, side, align and side offset place it; it flips when there is no room. Escape or a click outside closes it. Press the buttons to open them. Inside the content, popover header groups a popover title and a popover description.
page:
box:
layout = "row"
gap = 12
popover:
popover trigger:
content = "Open popover"
end
popover content:
popover header:
popover title:
content = "Dimensions"
end
popover description:
content = "Set the size of the layer."
end
end
end
end
popover:
popover trigger:
variant = "secondary"
content = "Bottom, aligned end"
end
popover content:
side = "bottom"
align = "end"
side offset = 12
popover title:
content = "Placement"
end
end
end
end
box:
height = 150
end
end| Element | Attributes | Values or notes |
|---|---|---|
popover content | side, align, side offset | side: top, right, bottom, left; align: start, center, end |
popover trigger | variant, size, content | button values |
popover header, title, description | content | the usual parts |
tooltip (Persian: راهنما)
A tooltip is a short hint that shows on hover and on keyboard focus, with a small arrow. side on the tooltip content picks the edge, and delay on the root waits that many milliseconds first (default 0). Hover the buttons in the example.
page:
box:
layout = "row"
gap = 12
padding = 40, 0
tooltip:
tooltip trigger:
content = "Top"
end
tooltip content:
content = "Shown above"
end
end
tooltip:
tooltip trigger:
content = "Right"
end
tooltip content:
side = "right"
content = "Shown at the right"
end
end
tooltip:
tooltip trigger:
content = "Bottom"
end
tooltip content:
side = "bottom"
content = "Shown below"
end
end
tooltip:
tooltip trigger:
content = "Left"
end
tooltip content:
side = "left"
content = "Shown at the left"
end
end
tooltip:
delay = 500
tooltip trigger:
variant = "ghost"
content = "Slow"
end
tooltip content:
content = "Waits half a second"
end
end
end
end| Element | Attributes | Values or notes |
|---|---|---|
tooltip | delay | milliseconds |
tooltip content | side, align, side offset | like the popover |
tooltip trigger | variant, size | button values |
hover card (Persian: کارت شناور)
A hover card is a richer tooltip: it opens when the pointer rests on the trigger (after 700 ms, and closes after 300 ms) and may hold any content, such as a profile preview. Hover the link in the example.
page:
hover card:
hover card trigger:
variant = "link"
content = "@salamlang"
end
hover card content:
width = 260
paragraph:
content = "Salam, a language for the web and for native apps."
end
end
end
box:
height = 120
end
end| Element | Attributes | Values or notes |
|---|---|---|
hover card | delay | default 700 ms |
hover card trigger | variant, size | button values |
hover card content | side, align, side offset | like the popover |
Menus
dropdown menu (Persian: منوی کشویی)
A dropdown menu opens a list of actions from a button. Inside menu content you can put menu item (with variant = "destructive", disabled and a menu shortcut), menu checkbox item, a menu radio group of menu radio item, menu label, menu group, menu separator and a submenu made of menu sub, menu sub trigger and menu sub content. The keyboard works as in a desktop menu: arrows, Home, End, typing the first letters, Enter or Space to choose, Escape to close. Each choice fires ds-select with detail.value and detail.checked. Press the button to open it.
page:
dropdown menu:
menu trigger:
content = "Open menu"
end
menu content:
menu label:
content = "My account"
end
menu group:
menu item:
content = "Profile"
menu shortcut:
content = "Ctrl P"
end
end
menu item:
content = "Settings"
end
menu item:
content = "Billing"
disabled = true
end
end
menu separator:
end
menu checkbox item:
checked = true
content = "Show toolbar"
end
menu separator:
end
menu radio group:
value = "light"
menu radio item:
value = "light"
content = "Light"
end
menu radio item:
value = "dark"
content = "Dark"
end
end
menu separator:
end
menu sub:
menu sub trigger:
content = "More"
end
menu sub content:
menu item:
content = "Export"
end
menu item:
content = "Share"
end
end
end
menu item:
variant = "destructive"
content = "Log out"
end
end
end
box:
height = 300
end
end| Element | Attributes | Values or notes |
|---|---|---|
menu item | variant, inset, disabled, value | default, destructive |
menu checkbox item | checked, inset, disabled | a toggle |
menu radio group, menu radio item | value, checked, disabled | one choice |
menu content | side, align, side offset | like the popover |
context menu (Persian: منوی راست کلیک)
A context menu opens at the pointer on a right click (or long press) over its trigger area. The context menu trigger wraps whatever should react, and context menu content holds the same items as a dropdown menu. Right click the dashed box.
page:
context menu:
context menu trigger:
box:
width = 280
height = 110
padding = 16
border = 1, "dashed", "#888888"
radius = 8
paragraph:
content = "Right click here"
end
end
end
context menu content:
menu item:
content = "Back"
end
menu item:
content = "Reload"
menu shortcut:
content = "Ctrl R"
end
end
menu separator:
end
menu checkbox item:
content = "Show bookmarks"
checked = true
end
menu item:
variant = "destructive"
content = "Delete"
end
end
end
box:
height = 120
end
end| Element | Attributes | Values or notes |
|---|---|---|
context menu trigger | (none) | the area that answers the right click |
context menu content | side, align, side offset | same items as the dropdown menu |
menubar (Persian: نوار منو)
A menubar is a row of menus like File, Edit and View in a desktop app. Each menubar menu holds a menubar trigger and a menu content. Once one is open, hovering another trigger switches to it, and Left and Right move between them. Click File in the example.
page:
menubar:
menubar menu:
menubar trigger:
content = "File"
end
menu content:
menu item:
content = "New tab"
menu shortcut:
content = "Ctrl T"
end
end
menu item:
content = "Print"
end
end
end
menubar menu:
menubar trigger:
content = "Edit"
end
menu content:
menu item:
content = "Undo"
end
menu item:
content = "Redo"
end
end
end
menubar menu:
menubar trigger:
content = "View"
end
menu content:
menu checkbox item:
content = "Always show bookmarks"
checked = true
end
end
end
end
box:
height = 150
end
end| Element | Attributes | Values or notes |
|---|---|---|
menubar | (none) | the bar |
menubar menu | (none) | one menu of the bar |
menubar trigger | content | the label on the bar |
navigation menu (Persian: منوی ناوبری)
A navigation menu is the main menu of a site. navigation menu list holds navigation menu items; an item has either a navigation menu trigger with a navigation menu content full of links, or a plain navigation menu link with url and active for the current page. It opens on hover or click and closes on Escape or a click outside. Hover Learn in the example.
page:
navigation menu:
navigation menu list:
navigation menu item:
navigation menu trigger:
content = "Learn"
end
navigation menu content:
link:
url = "/learn/"
content = "Lessons"
end
link:
url = "/std/"
content = "Standard library"
end
end
end
navigation menu item:
navigation menu trigger:
content = "Tools"
end
navigation menu content:
link:
url = "/editor/"
content = "Editor"
end
end
end
navigation menu item:
navigation menu link:
url = "/docs"
active = true
content = "Docs"
end
end
end
end
box:
height = 150
end
end| Element | Attributes | Values or notes |
|---|---|---|
navigation menu link | url, active | the current page gets active = true |
navigation menu trigger, content | content | the opening part |