# `LedgerUI.Components.AppShell`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/app_shell.ex#L1)

The application shell: the page frame, the main sidebar (the icon rail), the sidebar panel with its
collapsible groups, the minimized panel, the sideblock, the horizontal navigation, the header, the
right sidebar, the framed menu, the page header and the mode toggles.

    <.app_shell id="shell" sidebar_open={@sidebar_open} on_toggle="sidebar">
      <:sidebar>
        <.main_sidebar current={@current_path}>
          <:logo navigate={~p"/"}><.icon name="grid" /></:logo>
          <:item navigate={~p"/dashboards"} label="Dashboards"><.icon name="home" /></:item>
        </.main_sidebar>
        <.sidebar_panel title="Layouts">
          <.sidebar_nav>
            <.sidebar_nav_link navigate={~p"/orders"} current={@current_path}>Orders</.sidebar_nav_link>
          </.sidebar_nav>
        </.sidebar_panel>
      </:sidebar>
      <:header><.header /></:header>
      <.page_header title="Avatar">
        <:crumb navigate={~p"/elements"}>Elements</:crumb>
        <:crumb>Avatar</:crumb>
      </.page_header>
    </.app_shell>

The state kept in `<body>` classes by other kits lives on the shell root: `is-sidebar-open`
(mirrored by the class `open`, so `LedgerUI.open/close/toggle(socket_or_js, "shell")` drive it),
`has-min-sidebar`, `navigation:sideblock`, `navigation:horizontal`, `is-header-blur` and
`is-header-not-sticky`.

Hooks used: `LedgerUI.AppShell`, `LedgerUI.Sidebar` (framed menu), `LedgerUI.RightSidebar`,
`LedgerUI.Clock` and `LedgerUI.MonochromeToggle`; dark mode is `theme_toggle/1` and
`theme_script/1` of `LedgerUI.Components.ThemeSwitch`.

Written for the `lu-*` stylesheet: where it has no class (the right sidebar, the framed rail,
the phone tab bar) the rules live in `priv/static/ledger_ui.css`, loaded after `ledger.css`.

# `app_shell`

## Attributes

* `id` (`:string`) - Defaults to `"app-shell"`.
* `layout` (`:string`) - Defaults to `"sidebar"`. Must be one of `"sidebar"`, `"minimal"`, `"sideblock"`, `"horizontal"`, or `"framed"`.
* `sidebar_open` (`:boolean`) - Defaults to `nil`.
* `full` (`:boolean`) - Full-screen app (`lu-app full`): no frame, border, radius or shadow, `min-height: 100vh`. Without it the non-framed layouts carry the same reset inline. Defaults to `false`.
* `header_blur` (`:boolean`) - Defaults to `true`.
* `header_sticky` (`:boolean`) - Defaults to `true`.
* `persist` (`:boolean`) - Defaults to `true`.
* `preloader` (`:boolean`) - Defaults to `false`.
* `on_toggle` (`:any`) - Defaults to `nil`.
* `target` (`:any`) - Defaults to `nil`.
* `main_class` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `aside` - Fixed parts: the right sidebar, drawers.
* `header` - The `header/1`.
* `inner_block`
* `sidebar` - The main sidebar and its panel, or the sideblock.
* `tab_bar` - A bottom bar of tabs for phones (`layout="framed"`): a `tab_bar/1`.

# `framed_sidebar`

The menu of the framed shell: the brand, an optional workspace and search, the navigation
(`rail_link/1`, `rail_module/1`) and the bottom items. It collapses to a rail of icons (anything
with the class `rail-label` goes away, badges become dots) and the choice is kept in
`localStorage`. Below 768px it is a top bar with a hamburger.

## Attributes

* `id` (`:string`) (required)
* `collapsed` (`:boolean`) - Defaults to `false`.
* `persist` (`:boolean`) - Defaults to `true`.
* `on_collapse` (`:string`) - Defaults to `nil`.
* `shortcut` (`:string`) - Defaults to `"b"`.
* `target` (`:any`) - Defaults to `nil`.
* `label` (`:string`) - Defaults to `"Main menu"`.
* `mobile_label` (`:string`) - Defaults to `"Menu"`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `bottom`
* `brand`
* `inner_block` (required)
* `search` - Accepts attributes:

  * `id` (`:string`)
  * `class` (`:string`)
  * `title` (`:string`)
  * `aria-label` (`:string`)
  * `phx-click` (`:any`)
  * `phx-target` (`:any`)
* `wordmark`
* `workspace`

# `header`

The header: the animated sidebar toggle, the search bar, the dark mode and monochrome toggles, the
notifications, the right sidebar toggle and a profile slot. With a `:nav` slot it is the
horizontal navigation header: the `:brand` and the navigation row below.

## Attributes

* `id` (`:string`) - Defaults to `"app-header"`.
* `toggle` (`:boolean`) - Defaults to `true`.
* `search` (`:boolean`) - Defaults to `true`.
* `search_placeholder` (`:string`) - Defaults to `"Search here..."`.
* `search_input` (`:map`) - Defaults to `%{}`.
* `theme_toggle` (`:boolean`) - Defaults to `true`.
* `monochrome_toggle` (`:boolean`) - Defaults to `true`.
* `right_sidebar` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `actions`
* `mobile_search`
* `brand` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `src` (`:string`)
  * `label` (`:string`)
* `nav`
* `notifications` - Accepts attributes:

  * `dot` (`:boolean`)
  * `label` (`:string`)
* `profile`
* `search_results`
* `start`

# `horizontal_nav_divider`

The line between the links of a horizontal navigation box.
## Attributes

* `class` (`:any`) - Defaults to `nil`.

# `horizontal_nav_link`

A link of a horizontal navigation box. A click closes the box.
## Attributes

* `active` (`:boolean`) - Defaults to `false`.
* `current` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["href", "navigate", "patch", "method", "replace"]`.
## Slots

* `inner_block` (required)

# `horizontal_nav_menu`

A dropdown of the horizontal navigation: an icon and a label, and a box of links.
## Attributes

* `id` (`:string`) (required)
* `label` (`:string`) (required)
* `active` (`:boolean`) - Defaults to `false`.
* `current` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `icon`
* `inner_block`
* `item` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `active` (`:boolean`)

# `icon_rail`

Same as `main_sidebar/1` (same attributes and slots), under the name the design vitrine uses.
## Attributes

* `id` (`:string`) - Defaults to `"main-sidebar"`.
* `current` (`:any`) - The current path (matched against each item's link), or an item's `name`. Defaults to `nil`.
* `centered` (`:boolean`) - Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `bottom`
* `item` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `label` (`:string`)
  * `icon` (`:string`) - The name of the icon the link shows (or put it in the slot).
  * `name` (`:any`) - Marks the item as active when `current` is this name.
  * `active` (`:boolean`)
  * `class` (`:any`)
  * `style` (`:string`)
* `logo` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `src` (`:string`)
  * `alt` (`:string`)

# `main_sidebar`

The main sidebar: the icon rail with the logo, the section links and the bottom links.
## Attributes

* `id` (`:string`) - Defaults to `"main-sidebar"`.
* `current` (`:any`) - The current path (matched against each item's link), or an item's `name`. Defaults to `nil`.
* `centered` (`:boolean`) - Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `bottom`
* `item` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `label` (`:string`)
  * `icon` (`:string`) - The name of the icon the link shows (or put it in the slot).
  * `name` (`:any`) - Marks the item as active when `current` is this name.
  * `active` (`:boolean`)
  * `class` (`:any`)
  * `style` (`:string`)
* `logo` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `src` (`:string`)
  * `alt` (`:string`)

# `main_sidebar_link`

One icon link of the main sidebar.
## Attributes

* `label` (`:string`) - The tooltip and the accessible name. Defaults to `nil`.
* `active` (`:boolean`) - Defaults to `false`.
* `current` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["href", "navigate", "patch", "method", "replace"]`.
## Slots

* `inner_block` (required)

# `monochrome_toggle`

The monochrome mode: the palette button of the header or a switch. It toggles `is-monochrome` on `<body>`.
## Attributes

* `id` (`:string`) - Defaults to `"monochrome-toggle"`.
* `variant` (`:string`) - Defaults to `"button"`. Must be one of `"button"`, or `"switch"`.
* `on_change` (`:any`) - Defaults to `nil`.
* `target` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block`

# `page_header`

The title of a page. `variant="inline"` is the row: title (with the breadcrumb above it), a
description and the `:actions` at the right, then the `:tabs`. `variant="page"` is the framed
shell's title block: a top row (the `:leading` slot, the crumbs, the clock and the bell) or a
`back` link, the badge, the title with a context line and the actions, and the tabs.

## Attributes

* `title` (`:string`) - The title text. Or give the `:title` slot. Defaults to `nil`.
* `title_class` (`:any`) - Classes of the `h1` (the canvas animates it with `mo-stg`). Defaults to `nil`.
* `variant` (`:string`) - Defaults to `"inline"`. Must be one of `"inline"`, or `"page"`.
* `description` (`:string`) - Defaults to `nil`.
* `back` (`:string`) - Defaults to `nil`.
* `back_label` (`:string`) - Defaults to `nil`.
* `badge_position` (`:string`) - Defaults to `"above"`. Must be one of `"above"`, or `"inline"`.
* `clock` (`:boolean`) - Defaults to `false`.
* `locale` (`:string`) - Defaults to `nil`.
* `bell` (`:boolean`) - Defaults to `false`.
* `bell_label` (`:string`) - Defaults to `"Notifications"`.
* `on_bell` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `actions`
* `badge`
* `crumb` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
* `icon`
* `inner_block`
* `leading`
* `notifications`
* `subtitle` - A description with markup, instead of `description`.
* `tabs`
* `heading` - The content of the `h1` with markup, instead of `title`.

# `rail_heading`

A small uppercase title over a group of `rail_link/1`s; hidden in the rail.
## Attributes

* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block` (required)

# `rail_link`

A page of the framed menu: the icon, the label, an optional badge and a tooltip for the rail.
## Attributes

* `label` (`:string`) (required)
* `badge` (`:string`) - Defaults to `nil`.
* `active` (`:boolean`) - Defaults to `false`.
* `current` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["href", "navigate", "patch", "method", "replace"]`.
## Slots

* `inner_block` (required)

# `rail_module`

A module of the framed menu: a button that opens the pages under it.
## Attributes

* `id` (`:string`) (required)
* `label` (`:string`) (required)
* `badge` (`:string`) - Defaults to `nil`.
* `open` (`:boolean`) - Defaults to `nil`.
* `current` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `icon` (required)
* `item` (required) - Accepts attributes:

  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `href` (`:string`)
  * `active` (`:boolean`)

# `rail_toggle`

A button that collapses and expands the `framed_sidebar/1` with that id, from anywhere.
## Attributes

* `for` (`:string`) (required) - The id of the `framed_sidebar/1`.
* `label` (`:string`) - Defaults to `"Collapse menu"`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block`

# `rail_user`

The person at the bottom of the framed menu: their picture and, outside the rail, their name.
## Attributes

* `name` (`:string`) (required)
* `subtitle` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block` (required)

# `rail_workspace`

The workspace switcher under the brand of the framed menu. It is a button: `phx-click` opens your list.
## Attributes

* `name` (`:string`) (required)
* `subtitle` (`:string`) - Defaults to `nil`.
* `initials` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block`

# `right_sidebar`

A drawer from the right with an overlay, a top row (`:title` and the close button), the content and
a `:footer`. Opened with `open`, `right_sidebar_toggle/1` or `LedgerUI.open/close/toggle(id)`; Esc,
the overlay and the close button close it.

## Attributes

* `id` (`:string`) (required)
* `open` (`:boolean`) - Defaults to `false`.
* `label` (`:string`) - Defaults to `"Sidebar"`.
* `persist_tab` (`:boolean`) - Defaults to `false`.
* `on_open` (`:any`) - Defaults to `nil`.
* `on_close` (`:any`) - Defaults to `nil`.
* `target` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `footer`
* `inner_block`
* `title`

# `right_sidebar_toggle`

The header button that toggles a `right_sidebar/1`.
## Attributes

* `target` (`:string`) (required)
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `shell_floating`

Same as `app_shell/1` (same attributes and slots), under the name the design vitrine uses.
## Attributes

* `id` (`:string`) - Defaults to `"app-shell"`.
* `layout` (`:string`) - Defaults to `"sidebar"`. Must be one of `"sidebar"`, `"minimal"`, `"sideblock"`, `"horizontal"`, or `"framed"`.
* `sidebar_open` (`:boolean`) - Defaults to `nil`.
* `full` (`:boolean`) - Full-screen app (`lu-app full`): no frame, border, radius or shadow, `min-height: 100vh`. Without it the non-framed layouts carry the same reset inline. Defaults to `false`.
* `header_blur` (`:boolean`) - Defaults to `true`.
* `header_sticky` (`:boolean`) - Defaults to `true`.
* `persist` (`:boolean`) - Defaults to `true`.
* `preloader` (`:boolean`) - Defaults to `false`.
* `on_toggle` (`:any`) - Defaults to `nil`.
* `target` (`:any`) - Defaults to `nil`.
* `main_class` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `aside` - Fixed parts: the right sidebar, drawers.
* `header` - The `header/1`.
* `inner_block`
* `sidebar` - The main sidebar and its panel, or the sideblock.
* `tab_bar` - A bottom bar of tabs for phones (`layout="framed"`): a `tab_bar/1`.

# `sidebar_min_divider`

The line between the lists of the minimized panel.
## Attributes

* `class` (`:any`) - Defaults to `nil`.

# `sidebar_min_group`

A list of icon links of the minimized panel.
## Attributes

* `class` (`:any`) - Defaults to `nil`.
## Slots

* `inner_block` (required)

# `sidebar_min_link`

An icon link of the minimized panel. Active links are accent soft, the others take `color`.
## Attributes

* `label` (`:string`) - Defaults to `nil`.
* `color` (`:string`) - Defaults to `"neutral"`. Must be one of `"neutral"`, `"primary"`, `"secondary"`, `"info"`, `"success"`, `"warning"`, or `"error"`.
* `active` (`:boolean`) - Defaults to `false`.
* `current` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["href", "navigate", "patch", "method", "replace"]`.
## Slots

* `inner_block` (required)

# `sidebar_nav`

A list of the sidebar panel (or the sideblock).
## Attributes

* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block` (required)

# `sidebar_nav_divider`

The line between the lists of the sidebar panel.
## Attributes

* `class` (`:any`) - Defaults to `nil`.

# `sidebar_nav_group`

A collapsible group of the sidebar panel. It opens when one of its items is active (or with `open`).
## Attributes

* `id` (`:string`) - Defaults to `sidebar-group-<label>`. Defaults to `nil`.
* `label` (`:string`) (required)
* `open` (`:boolean`) - Defaults to `nil`.
* `name` (`:string`) - Groups with the same name open one at a time. Defaults to `"sidebar-nav"`.
* `current` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `item` (required) - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `active` (`:boolean`)

# `sidebar_nav_link`

A plain link of the sidebar panel, active with `active` or when its path is `current`.
## Attributes

* `active` (`:boolean`) - Defaults to `false`.
* `current` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["href", "navigate", "patch", "method", "replace"]`.
## Slots

* `inner_block` (required)

# `sidebar_panel`

The sidebar panel next to the main sidebar: its title and the scrolling body.
## Attributes

* `title` (`:string`) (required)
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block` (required)

# `sidebar_panel_min`

The minimized sidebar panel (`layout="minimal"`): a header, the icon links and a footer.
## Attributes

* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `footer`
* `header`
* `inner_block` (required)

# `sidebar_profile`

The avatar at the bottom of the main sidebar and the profile box it opens on its right.
## Attributes

* `id` (`:string`) (required)
* `src` (`:string`) (required)
* `alt` (`:string`) - Defaults to `"avatar"`.
* `name` (`:string`) (required)
* `subtitle` (`:string`) - Defaults to `nil`.
* `status` (`:string`) - Defaults to `"success"`. Must be one of `nil`, `""`, `"success"`, `"warning"`, `"error"`, `"info"`, or `"neutral"`.
* `href` (`:string`) - Defaults to `nil`.
* `navigate` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `footer`
* `item` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `method` (`:string`)
  * `color` (`:string`)
  * `title` (`:string`)
  * `description` (`:string`)

# `sidebar_toggle`

The animated hamburger: three bars that turn into an arrow while the sidebar is open.
## Attributes

* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `sideblock`

The sideblock (`layout="sideblock"`): one wide sidebar with the logo and the navigation.
## Attributes

* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block` (required)
* `logo` - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `src` (`:string`)
  * `alt` (`:string`)

# `sub_nav`

The sub navigation next to the icon rail: a title and groups of links that open and close.

    <.sub_nav title="Cases">
      <:group label="Status">
        <.sidebar_nav_link navigate={~p"/cases/open"}>Open</.sidebar_nav_link>
      </:group>
    </.sub_nav>

## Attributes

* `title` (`:string`) (required)
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `group` - A collapsible group under the title: a caption and the links. Accepts attributes:

  * `label` (`:string`) (required)
  * `open` (`:boolean`) - Open at first (the default).
* `inner_block` - What goes before the groups.

# `tab_bar`

A phone's bottom bar of tabs: one icon per section, the current one in the accent color.
## Attributes

* `label` (`:string`) - Defaults to `"Sections"`.
* `current` (`:string`) - Defaults to `nil`.
* `variant` (`:string`) - Defaults to `"default"`. Must be one of `"default"`, or `"canvas"`.
* `match` (`:string`) - Defaults to `"exact"`. Must be one of `"exact"`, or `"prefix"`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `tab` (required) - Accepts attributes:

  * `href` (`:string`)
  * `navigate` (`:string`)
  * `patch` (`:string`)
  * `label` (`:string`)
  * `active` (`:boolean`)
  * `class` (`:string`)
  * `match` (`:string`)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
