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

The app top bar: a container (`navbar/1`) and small pieces to put in it. The right side keeps the
same vocabulary (search, notifications, theme, language and the user); the variants change what
goes on the left and the visual weight.

    <.navbar>
      <.navbar_crumbs items={[%{label: "Início", navigate: ~p"/"}, %{label: "Site novo"}]} />
      <:end>
        <.navbar_search placeholder="Buscar…" phx-click={JS.exec("data-show", to: "#palette")} />
        <.navbar_bell dot />
        <.theme_switch id="theme" variant="icons" size="sm" />
        <.navbar_user id="me" user={@user}>
          <:menu>
            <.navbar_menu_head user={@user} />
            <.navbar_menu_item icon="user" navigate={~p"/perfil"}>Perfil</.navbar_menu_item>
            <.navbar_menu_item icon="logout" danger href={~p"/sair"} method="delete">Sair</.navbar_menu_item>
          </:menu>
        </.navbar_user>
      </:end>
    </.navbar>

`variant`: `"default"` (64px, a line under it), `"float"` (a detached raised bar), `"clear"`
(transparent, over a hero), `"dense"` (48px) or `"mobile"` (56px). `size="sm"` is 52px. Slots:
`inner_block` (the left side), `:center`, `:end` (the right side) and `:tabs`, which makes the bar
two rows (the tabs row under the content).

The slots are rendered straight inside `<header class="lu-topbar">` (flex row), so the items are
its direct children and the crumbs take the free space.

# `navbar`

## Attributes

* `variant` (`:string`) - `canvas` is the same as `default` (the canvas's own bar). Defaults to `"default"`. Must be one of `"default"`, `"canvas"`, `"float"`, `"clear"`, `"dense"`, or `"mobile"`.
* `size` (`:string`) - Defaults to `"md"`. Must be one of `"md"`, or `"sm"`.
* `id` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `inner_block` - The left side.
* `center` - Between the left and the right: `navbar_links/1`, a wide `navbar_search/1`.
* `end` - The right side.
* `tabs` - `navbar_tabs/1`: makes the bar two rows.

# `navbar_avatars`

The people on the page, as overlapping avatars; the rest is a `+N` bubble.
## Attributes

* `users` (`:list`) (required)
* `max` (`:integer`) - Defaults to `3`.
* `total` (`:integer`) - How many people there are (default: the length of `users`). Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `navbar_bell`

The notifications button; `dot` shows the dot of something unread.
## Attributes

* `dot` (`:boolean`) - There is something unread. Defaults to `false`.
* `count` (`:integer`) - A count badge (the `lu-bell` form) instead of the dot. Defaults to `nil`.
* `label` (`:string`) - Defaults to `"Notifications"`.
* `size` (`:string`) - Defaults to `"md"`. Must be one of `"md"`, or `"sm"`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["href", "navigate", "patch"]`.

# `navbar_brand`

The logo and the name of the app.
## Attributes

* `name` (`:string`) - Defaults to `nil`.
* `logo` (`:string`) - The letter in the logo (default: the first of `name`). Defaults to `nil`.
* `src` (`:string`) - A picture for the logo instead of the letter. Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `navbar_chip`

A selector in a path of selectors (organization, project). `phx-click` opens the list.
## Attributes

* `label` (`:string`) (required)
* `square` (`:string`) - The text in the square (2 or 3 letters). Defaults to `nil`.
* `color` (`:string`) - The CSS color of the square. Defaults to `nil`.
* `tag` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `navbar_crumbs`

The path to the page. Each item is `%{label: "...", navigate: path}` (or `href` / `patch`); the
last one, the page itself, is the current one, and an item with no link is plain text.

## Attributes

* `items` (`:list`) (required)
* `label` (`:any`) - The `aria-label` of the `nav` (`nil` leaves it out). Defaults to `"Breadcrumb"`.
* `variant` (`:string`) - `plain` is the bare trail of the app top bar (larger text, no chips). Defaults to `"canvas"`. Must be one of `"canvas"`, or `"plain"`.
* `icon` (`:string`) - An icon before the trail (`grid`). Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `navbar_env`

The environment pill (`Produção`, `Homologação`); `tone` is `ok` (green) or `warn` (amber).
## Attributes

* `label` (`:string`) (required)
* `tone` (`:string`) - Defaults to `"ok"`. Must be one of `"ok"`, or `"warn"`.
* `compact` (`:boolean`) - Only the status dot (`lu-stat-dot`), the label as its title. Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `navbar_icon`

An icon button of the bar (search on a small screen, help, the menu of the mobile bar).
## Attributes

* `name` (`:string`) (required) - A Hugeicons name.
* `label` (`:string`) (required)
* `size` (`:string`) - Defaults to `"md"`. Must be one of `"md"`, or `"sm"`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["href", "navigate", "patch"]`.

# `navbar_lang`

The language switcher: a small segmented group. `locales` is a list of codes (`["PT", "EN"]`,
with `current`) or of maps `%{code:, navigate:, active:, click:, label:}`.

## Attributes

* `locales` (`:list`) (required)
* `current` (`:string`) - Defaults to `nil`.
* `label` (`:string`) - Defaults to `"Language"`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `navbar_links`

The main links, centered. Items are `%{label:, navigate:, active:}` (`href` / `patch` work too).
The active one is the item with `active: true` or the one whose link equals `current`.

## Attributes

* `items` (`:list`) (required)
* `current` (`:string`) - Defaults to `nil`.
* `label` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `navbar_menu_head`

The head of the user menu: the avatar, the name and the email, and a `:badge` (the role) at the end.
## Attributes

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

* `badge`

# `navbar_menu_item`

An item of the menu: a link (`navigate`, `href`, `patch`, with `method="delete"` for a sign-out)
or, with only `phx-click`, an action.

## Attributes

* `icon` (`:string`) - Defaults to `nil`.
* `kbd` (`:string`) - Defaults to `nil`.
* `danger` (`:boolean`) - Defaults to `false`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["href", "navigate", "patch", "method", "download", "target", "rel"]`.
## Slots

* `inner_block` (required)

# `navbar_menu_row`

A row of the menu with a label and a control at the end (`theme_switch/1`, `navbar_lang/1`).
## Attributes

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

* `inner_block` (required)

# `navbar_menu_status`

The status line of the menu: a green dot, the label and an `:action` at the end.
## Attributes

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

* `action`

# `navbar_search`

The search field of the bar. It is a trigger, not an input: with `phx-click` it becomes a button
(role and tabindex) that opens the command palette.

## Attributes

* `placeholder` (`:string`) - Defaults to `"Search"`.
* `kbd` (`:string`) - The shortcut shown at the end; `nil` hides it. Defaults to `"⌘K"`.
* `wide` (`:boolean`) - Defaults to `false`.
* `input` (`:boolean`) - A real `<input>` with the placeholder, instead of the static text (a field of the bar). Defaults to `false`.
* `width` (`:string`) - A CSS width ("240px", "100%"). Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted. Supports all globals plus: `["phx-click"]`.

# `navbar_sep`

The thin vertical line between the icons and the user.
## Attributes

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

# `navbar_slash`

The `/` between two selectors.
## Attributes

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

# `navbar_sync`

The save state: a green check and a muted text (`Salvo há 2 min`).
## Attributes

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

# `navbar_tabs`

The tabs of the page, for the `:tabs` slot of `navbar/1`. Items are those of `navbar_links/1` plus an optional `count`.
## Attributes

* `items` (`:list`) (required)
* `current` (`:string`) - Defaults to `nil`.
* `label` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

# `navbar_title`

The centered title of the mobile bar.
## Attributes

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

* `inner_block` (required)

# `navbar_user`

The user of the bar: the avatar, with a status ring (`"ring"`) or with the name (`"named"`).
Without the `:menu` slot it is a plain avatar (a button when it has `phx-click`). With it, the
button opens a raised panel (`role="menu"`, hidden at first; `id` is required) toggled with
`Phoenix.LiveView.JS`: a click outside closes it.

## Attributes

* `user` (`:map`) (required) - `%{name, email, role, initials, avatar, color}`.
* `variant` (`:string`) - Defaults to `"avatar"`. Must be one of `"avatar"`, `"ring"`, or `"named"`.
* `size` (`:integer`) - Avatar size in px (32; 26 for `named`). Defaults to `nil`.
* `id` (`:string`) - Required with a `:menu`. Defaults to `nil`.
* `label` (`:string`) - Defaults to `"Account menu"`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `menu` - The content of the panel: `navbar_menu_*` pieces, links with `role="menuitem"`, `<hr />`.

# `navbar_workspace`

The workspace switcher: logo, name, a line under it and a chevron. `phx-click` opens your menu.
## Attributes

* `name` (`:string`) (required)
* `sub` (`:string`) - Defaults to `nil`.
* `logo` (`:string`) - Defaults to `nil`.
* `src` (`:string`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.

---

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