The frame of an app: a sidebar that collapses to a rail, a header and a panel with the page. ⌘B (or Ctrl+B)
and the toggle button switch the sidebar between open (248px) and a rail of icons (60px) whose items show their
name on hover; below 1024px the sidebar is a drawer over the page, closed by the backdrop, Esc or following a
link. The choice is kept in the dui_sidebar cookie, so DevactionUI.Shell.SidebarCookie and on_mount/4
render it right on the first paint (sidebar_open); the open or closed state of each group is kept in the
local storage. The hook is DevactionUI.Shell and the shell tells LiveView to leave its own attributes alone,
so a patch does not undo what the person chose.
variant is the layout: "classic" (a sidebar beside the panel), "topbar" (the sidebar becomes a bar on top),
"split" (a list column between the sidebar and the panel, for list and detail), "centered" (the page in a
narrow centred column, with the sidebar as a bar on top like topbar) and "docs" (a toc column at the end). content_width="read" limits the page to the
reading width. The shell is as tall as the screen; to put it in a box, set --shell-h (style="--shell-h: 460px").
The slots are sidebar (built from sidebar_head/1, sidebar_search/1, sidebar_nav/1, sidebar_group/1,
sidebar_item/1, sidebar_foot/1 and sidebar_user/1), header (usually a DevactionUI.Breadcrumb), header_actions, list, toc, and the
page itself. A shell with a sidebar needs sidebar_label, open_label and close_label (the toggle button
says which one by its state); without them it raises, so the library carries no language of its own. The
toggle's icon is the toggle_icon slot.
<Shell.shell
id="app"
sidebar_open={@sidebar_open}
sidebar_label="Main"
open_label="Open menu"
close_label="Collapse menu"
>
<:sidebar>
<Shell.sidebar_head name="Acme" subtitle="Workspace"><:logo>A</:logo></Shell.sidebar_head>
<Shell.sidebar_nav>
<Shell.sidebar_item tip="Projects" navigate="/projects" current>Projects</Shell.sidebar_item>
</Shell.sidebar_nav>
</:sidebar>
<:header><Breadcrumb.breadcrumb label="You are here" items={[%{label: "Projects"}]} /></:header>
The page.
</Shell.shell>
Summary
Functions
The on_mount that puts @sidebar_open in every LiveView of a live_session, from the session value
DevactionUI.Shell.SidebarCookie wrote.
The shell: sidebar, header and panel.
The foot of the sidebar: settings, the account.
A group of items under a heading that collapses. In the rail the heading goes and the group is a block between two lines.
The head of the sidebar: the workspace. The text goes away in the rail.
An item of the sidebar: a link to navigate, patch or href.
The scrolling list of the sidebar's groups and items.
A row under the head for a search field; it goes away in the rail.
The account card at the foot of the sidebar: avatar, name and e-mail. Only the avatar stays in the rail.
Functions
@spec on_mount(:sidebar, map(), map(), Phoenix.LiveView.Socket.t()) :: {:cont, Phoenix.LiveView.Socket.t()}
The on_mount that puts @sidebar_open in every LiveView of a live_session, from the session value
DevactionUI.Shell.SidebarCookie wrote.
@spec shell(map()) :: Phoenix.LiveView.Rendered.t()
The shell: sidebar, header and panel.
Attributes
id(:string) - Defaults to"shell".variant(:string) - Defaults to"classic". Must be one of"classic","topbar","split","centered", or"docs".sidebar_open(:boolean) - the state the server renders; the browser keeps what the person chose after that. Defaults totrue.sidebar_label(:string) - names the sidebar for assistive technology. Defaults tonil.open_label(:string) - the toggle button when the sidebar is collapsed. Defaults tonil.close_label(:string) - the toggle button when the sidebar is open. Defaults tonil.content_width(:string) - Defaults tonil.Must be one ofnil, or"read".class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
sidebarheaderheader_actionslist- the middle column of thesplitvariant.toc- the page index of thedocsvariant.toggle_icon- the icon of the toggle button; a typographic glyph when empty.inner_block(required)
@spec sidebar_foot(map()) :: Phoenix.LiveView.Rendered.t()
The foot of the sidebar: settings, the account.
Attributes
class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required)
@spec sidebar_group(map()) :: Phoenix.LiveView.Rendered.t()
A group of items under a heading that collapses. In the rail the heading goes and the group is a block between two lines.
Attributes
id(:string) (required) - also the key the open state is kept under.label(:string) (required)open(:boolean) - Defaults totrue.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
icon- the chevron of the heading; it turns when the group closes.inner_block(required)
@spec sidebar_head(map()) :: Phoenix.LiveView.Rendered.t()
The head of the sidebar: the workspace. The text goes away in the rail.
Attributes
name(:string) (required)subtitle(:string) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
logo(required) - the mark of the workspace, 30px.menu- a button at the end, such as a workspace switcher; hidden in the rail.
@spec sidebar_item(map()) :: Phoenix.LiveView.Rendered.t()
An item of the sidebar: a link to navigate, patch or href.
Attributes
tip(:string) (required) - the name of the item in the rail, where the text is hidden; also its accessible name.current(:boolean) - Defaults tofalse.badge(:any) - Defaults tonil.badge_tone(:string) - Defaults tonil.Must be one ofnil, or"ai".dot(:boolean) - marks the item in the rail, such as a PR with a block. Defaults tofalse.class(:any) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["navigate", "patch", "href", "method"].
Slots
icon- the 18px icon.inner_block(required)sub- indented items under this one, with a line on the left.
@spec sidebar_search(map()) :: Phoenix.LiveView.Rendered.t()
A row under the head for a search field; it goes away in the rail.
Attributes
class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
inner_block(required) - a search field, such as anInputGroupwith a⌘Khint.
@spec sidebar_user(map()) :: Phoenix.LiveView.Rendered.t()
The account card at the foot of the sidebar: avatar, name and e-mail. Only the avatar stays in the rail.
Attributes
name(:string) (required)email(:string) (required)class(:any) - Defaults tonil.- Global attributes are accepted. Supports all globals plus:
["navigate", "patch", "href", "method"].
Slots
avatar(required) - the person's avatar, 32px.icon- the end of the card, such as a chevron; it goes away in the rail.