Skip to content
Components

Sidebar

A sticky app sidebar that folds to an icon rail and remembers the choice.

After the one-time setup, call the helper directly from ERB. No component import is needed.

<%= lc_sidebar cookie: "docs_sidebar", rail_below: false, class: "static h-128 rounded-2xl bg-muted" do |sidebar| %>
  <%= sidebar.header do %>
    <a href="#" class="text-subheading font-bold text-inherit no-underline" aria-label="Studio home">
      <span class="lc-rail:hidden">Studio</span><span class="hidden lc-rail:inline" aria-hidden="true">S</span>
    </a>
  <% end %>
  <%= sidebar.body do %>
    <%= lc_nav_list label: "Main" do |nav| %>
      <%= nav.group "Workspace" do %>
        <%= nav.link "Home", "#home", icon: "home", current: true, title: "Home" %>
        <%= nav.link "Projects", "#projects", icon: "folder", title: "Projects" %>
        <%= nav.link "Messages", "#messages", icon: "chat-bubble-left-right", title: "Messages" %>
      <% end %>
      <%= nav.group "Account" do %>
        <%= nav.link "Settings", "#settings", icon: "cog-6-tooth", title: "Settings" %>
      <% end %>
    <% end %>
  <% end %>
  <%= sidebar.footer do %>
    <%= sidebar.account "Ada Lovelace", detail: "ada@example.com", avatar: lc_avatar("AL", size: :sm, class: "bg-primary-soft text-primary"), id: "my-component-account" do %>
      <%= lc_menu_option "Settings", icon: "cog-6-tooth", href: "#settings" %>
      <%= lc_menu_option "Sign out", icon: "arrow-right-start-on-rectangle", href: "#sign-out" %>
    <% end %>
  <% end %>
<% end %>
<%= lc_sidebar cookie: "docs_sidebar", rail_below: false, class: "static h-128 rounded-2xl bg-muted" do |sidebar| %>
  <%= sidebar.header do %>
    <a href="#" class="text-subheading font-bold text-inherit no-underline" aria-label="Studio home">
      <span class="lc-rail:hidden">Studio</span><span class="hidden lc-rail:inline" aria-hidden="true">S</span>
    </a>
  <% end %>
  <%= sidebar.body do %>
    <%= lc_nav_list label: "Main" do |nav| %>
      <%= nav.group "Workspace" do %>
        <%= nav.link "Home", "#home", icon: "home", current: true, title: "Home" %>
        <%= nav.link "Projects", "#projects", icon: "folder", title: "Projects" %>
        <%= nav.link "Messages", "#messages", icon: "chat-bubble-left-right", title: "Messages" %>
      <% end %>
      <%= nav.group "Account" do %>
        <%= nav.link "Settings", "#settings", icon: "cog-6-tooth", title: "Settings" %>
      <% end %>
    <% end %>
  <% end %>
  <%= sidebar.footer do %>
    <%= sidebar.account "Ada Lovelace", detail: "ada@example.com", avatar: lc_avatar("AL", size: :sm, class: "bg-primary-soft text-primary"), id: "example-0-account" do %>
      <%= lc_menu_option "Settings", icon: "cog-6-tooth", href: "#settings" %>
      <%= lc_menu_option "Sign out", icon: "arrow-right-start-on-rectangle", href: "#sign-out" %>
    <% end %>
  <% end %>
<% end %>
<%= lc_sidebar cookie: "docs_sidebar_rail", state: "collapsed", class: "static h-96 rounded-2xl bg-muted" do |sidebar| %>
  <%= sidebar.header do %>
    <a href="#" class="text-subheading font-bold text-inherit no-underline" aria-label="Studio home">
      <span class="lc-rail:hidden">Studio</span><span class="hidden lc-rail:inline" aria-hidden="true">S</span>
    </a>
  <% end %>
  <%= sidebar.body do %>
    <%= lc_nav_list label: "Main" do |nav| %>
      <%= nav.link "Home", "#home", icon: "home", current: true, title: "Home" %>
      <%= nav.link "Projects", "#projects", icon: "folder", title: "Projects" %>
    <% end %>
  <% end %>
  <%= sidebar.footer do %>
    <%= sidebar.account "Ada Lovelace", detail: "ada@example.com", avatar: lc_avatar("AL", size: :sm, class: "bg-primary-soft text-primary"), id: "example-1-account" do %>
      <%= lc_menu_option "Sign out", icon: "arrow-right-start-on-rectangle", href: "#sign-out" %>
    <% end %>
  <% end %>
<% end %>

Helpers render semantic HTML and include their interaction wiring. Pass native attributes through class:, data:, aria: and the usual Rails options. Blocks use captured ERB content.

lc_sidebar

lc_sidebar(label: lc_t("lostcoords.ui.sidebar.label"), cookie: "lc_sidebar", rail_below: :xl, state: nil, **attributes, &block)
InputDefaultValues
labellc_t("lostcoords.ui.sidebar.label")Accessible name, visible where applicable
cookie"lc_sidebar"—
rail_below:xl:md · :lg · :xl · :2xl
statenil—
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured Rails ERB content

lc_sidebar yields a builder, sidebar, with these parts. Each part carries data-slot and merges class: and native attributes.

InputDefaultValues
toggletruetrue · false
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured Rails ERB content
InputDefaultValues
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
InputDefaultValues
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured Rails ERB content
InputDefaultValues
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured Rails ERB content
InputDefaultValues
nameRequired—
detailnil—
avatarnil—
id"sidebar-account"—
align:start—
attributes{}Native HTML attributes; class:, data: and aria: merge with defaults
blockCaptured blockCaptured Rails ERB content

The examples also use lc_nav_list, lc_avatar, and lc_menu_option. Each is documented on its own page.

Styling and extension

Use class: to merge utilities, native attributes for application behavior, and the theming guide for the shared palette. For custom markup, the advanced class helpers expose the same styles, including glass surfaces and class merging.

API JSON · LLM reference