Skip to content
Components

Application header

A glass header with navigation, an account menu and room for your brand.

Open preview ↗

Interact with the example above, or open it in a full window.

After setting up the library, copy the example files into your app and adapt the content. These are composition references, with no block API to install or import.

Replace the sample brand, links and account actions with your application's content.

lc_app_header handles the glass and the scroll behavior. Keep destinations in header.nav and account actions in a menu inside header.actions.

The preview renders this ERB and loads these styles and interactions.

app/views/shared/_application_header.html.erb

<div class="min-h-screen">
  <%= lc_app_header bar: { class: "max-w-5xl" } do |header| %>
    <%= header.brand "#overview", label: "Studio home" do %>
      <span class="grid size-8 place-items-center rounded-xl bg-foreground text-background"><%= lc_icon "square-3-stack-3d", options: { class: "size-4.5", "aria-hidden": true } %></span>
      Studio
    <% end %>
    <%= header.nav label: "Workspace", class: "max-sm:hidden" do |nav| %>
      <%= nav.link "Overview", "#overview", current: true %>
      <%= nav.link "Projects", "#projects" %>
      <%= nav.link "People", "#people" %>
    <% end %>
    <%= header.actions do %>
      <span class="hidden sm:inline-flex"><%= lc_badge "Personal workspace" %></span>
      <div class="relative" data-controller="lc-menu">
        <button class="<%= lc_icon_button_class(shape: :circle, size: :sm) %>" type="button" aria-label="Account menu" aria-haspopup="menu" aria-expanded="false" aria-controls="header-account-menu" data-lc-menu-target="trigger" data-action="lc-menu#toggle">
          <%= lc_avatar "AL", size: :sm, class: "bg-primary-soft text-primary" %>
        </button>
        <div id="header-account-menu" class="<%= lc_menu_popover_class %>" role="menu" aria-label="Account" data-lc-menu-target="popover">
          <%= lc_menu_option "Alex Lee · Personal workspace", href: "#people" %>
          <%= lc_menu_option "Workspace overview", href: "#overview" %>
          <%= lc_menu_option "See projects", href: "#projects" %>
        </div>
      </div>
      <div class="relative sm:hidden" data-controller="lc-menu">
        <%= lc_icon_button "Workspace menu", icon: "bars-3", size: :sm, aria: { haspopup: "menu", expanded: false, controls: "header-workspace-menu" }, data: { lc_menu_target: "trigger", action: "lc-menu#toggle" } %>
        <div id="header-workspace-menu" class="<%= lc_menu_popover_class %>" role="menu" aria-label="Workspace" data-lc-menu-target="popover">
          <%= lc_menu_option "Overview", href: "#overview" %>
          <%= lc_menu_option "Projects", href: "#projects" %>
          <%= lc_menu_option "People", href: "#people" %>
        </div>
      </div>
    <% end %>
  <% end %>
  <main class="isolate mx-auto flex max-w-4xl flex-col gap-12 px-5 pt-8 pb-16 sm:px-8 sm:pt-12">
    <section id="overview" class="lc-anchor-target flex flex-col gap-6">
      <div class="flex flex-col gap-3">
        <%= lc_text "Your workspace, at a glance", size: :caption, tone: :muted %>
        <h1 class="text-4xl font-semibold tracking-tight sm:text-5xl">Room for good work.</h1>
        <p class="max-w-lg text-muted-foreground">A little space for your projects, your people, and whatever comes next.</p>
      </div>
      <div class="grid gap-4 sm:grid-cols-3">
        <% [ [ "Projects in motion", "06", "rectangle-stack" ], [ "Your collaborators", "12", "users" ], [ "This week’s milestones", "03", "flag" ] ].each do |label, number, icon| %>
          <%= lc_card class: "flex flex-col gap-6" do %>
            <div class="flex items-center justify-between gap-3"><span class="text-sm text-muted-foreground"><%= label %></span><%= lc_icon icon, options: { class: "size-5 shrink-0 text-muted-foreground", "aria-hidden": true } %></div>
            <p class="text-4xl font-semibold tracking-tight tabular-nums"><%= number %></p>
          <% end %>
        <% end %>
      </div>
    </section>

    <section id="projects" class="lc-anchor-target flex flex-col gap-4">
      <div class="flex min-h-11 items-center justify-between gap-3"><h2 class="text-xl font-semibold">In the studio</h2><%= lc_badge "3 featured" %></div>
      <% [ [ "Brand refresh", "A fresh look for a familiar idea.", "swatch", :primary, "In progress" ], [ "Summer collection", "Objects made for everyday moments.", "sun", :neutral, "Taking shape" ], [ "Field notes", "Small observations, collected together.", "book-open", :primary, "Ready to share" ] ].each do |title, description, icon, tone, status| %>
        <%= lc_card class: "flex items-center gap-4" do %>
          <%= lc_icon_badge shape: :circle, icon: icon, tone: tone, size: :sm%>
          <div class="flex min-w-0 flex-1 flex-col gap-1"><h3 class="font-semibold"><%= title %></h3><p class="text-sm text-muted-foreground"><%= description %></p></div>
          <span class="hidden text-xs text-muted-foreground sm:block"><%= status %></span>
        <% end %>
      <% end %>
    </section>

    <section id="people" class="lc-anchor-target flex flex-col gap-4">
      <h2 class="text-xl font-semibold">Good company</h2>
      <%= lc_card class: "flex flex-col gap-5" do %>
        <% [ [ "AL", "Alex Lee", "Designer" ], [ "SK", "Sam Kim", "Writer" ], [ "JR", "Jamie Reed", "Maker" ] ].each do |initials, name, role| %>
          <div class="flex items-center gap-3"><%= lc_avatar initials, class: "bg-background text-muted-foreground" %><div class="flex-1"><p class="text-sm font-semibold"><%= name %></p><p class="text-sm text-muted-foreground"><%= role %></p></div><%= lc_badge "Available", tone: :primary, class: "rounded-full text-sm" %></div>
        <% end %>
      <% end %>
    </section>
  </main>
</div>
← All blocks