Sidebar
A sticky app sidebar that folds to an icon rail and remembers the choice.
Usage
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 %>
Examples
Navigation and an account menu
<%= 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 %>
Folded to a rail
<%= 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 %>
API reference
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
| Input | Default | Values |
|---|---|---|
| label | lc_t("lostcoords.ui.sidebar.label") | Accessible name, visible where applicable |
| cookie | "lc_sidebar" | — |
| rail_below | :xl | :md · :lg · :xl · :2xl |
| state | nil | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
lc_sidebar yields a builder, sidebar, with these parts. Each part carries data-slot and merges class: and native attributes.
sidebar.header
| Input | Default | Values |
|---|---|---|
| toggle | true | true · false |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
sidebar.toggle
| Input | Default | Values |
|---|---|---|
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
sidebar.body
| Input | Default | Values |
|---|---|---|
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
sidebar.footer
| Input | Default | Values |
|---|---|---|
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
sidebar.account
| Input | Default | Values |
|---|---|---|
| name | Required | — |
| detail | nil | — |
| avatar | nil | — |
| id | "sidebar-account" | — |
| align | :start | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured 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.