Tab bar
Links to the views of a page as a row of underlined tabs, with counts.
Usage
After the one-time setup, call the helper directly from ERB. No component import is needed.
<%= lc_tab_bar label: "Inbox", fill: true, class: "w-full" do |bar| %>
<%= bar.link "All", "#all", current: true, count: 128 %>
<%= bar.link "Mentions", "#mentions", count: 12 %>
<%= bar.link "Replies", "#replies", count: 4 %>
<%= bar.link "Archived", "#archived" %>
<% end %>
Examples
Tabs that share the row
<%= lc_tab_bar label: "Inbox", fill: true, class: "w-full" do |bar| %>
<%= bar.link "All", "#all", current: true, count: 128 %>
<%= bar.link "Mentions", "#mentions", count: 12 %>
<%= bar.link "Replies", "#replies", count: 4 %>
<%= bar.link "Archived", "#archived" %>
<% end %>
Scrolling when it overflows
<%= lc_tab_bar label: "Timeline filter", class: "w-full max-w-sm" do |bar| %>
<%= bar.link "Everything", "#everything", count: 86 %>
<%= bar.link "Replies", "#replies", current: true, count: 31 %>
<%= bar.link "Messages", "#messages", count: 18 %>
<%= bar.link "Likes", "#likes", count: 25 %>
<%= bar.link "Bookmarks", "#bookmarks", count: 7 %>
<%= bar.link "Mentions", "#mentions", count: 5 %>
<% 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_tab_bar
lc_tab_bar(label:, fill: false, **attributes, &block)
| Input | Default | Values |
|---|---|---|
| label | Required | Accessible name, visible where applicable |
| fill | false | true · false |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
| block | Captured block | Captured Rails ERB content |
lc_tab_bar yields a builder, bar, with these parts. Each part carries data-slot and merges class: and native attributes.
bar.link
bar.link(label, url, current: false, count: nil, **attributes)
| Input | Default | Values |
|---|---|---|
| label | Required | Accessible name, visible where applicable |
| url | Required | — |
| current | false | true · false |
| count | nil | — |
| attributes | {} | Native HTML attributes; class:, data: and aria: merge with defaults |
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.