Tabs

LesliView::Components::Tabs renders client-side tabs with Alpine.js. The component requires Alpine to be loaded by the host assets.

<%= render LesliView::Components::Tabs.new(active_tab: "details") do |tabs| %>
    <% tabs.with_tab(id: "details", title: "Details") do %>
        <p>Ticket details</p>
    <% end %>

    <% tabs.with_tab(id: "activity", title: "Activity", icon: "history") do %>
        <p>Recent changes</p>
    <% end %>
<% end %>

active_tab: selects the initial tab; otherwise the first tab is used. Set vertical: true for the vertical presentation. Each with_tab accepts id:, title:, and an optional Material Symbol icon:. When id: is omitted, a normalized ID is generated from the title and falls back to the tab position.

The component uses Tailwind CSS for presentation and includes tab, tablist, and tabpanel semantics. Tabs can be selected with a pointer, Tab, Enter, Space, or the arrow keys.

Component files

lib/lesli_view/components/
    tabs.rb
    tabs/
        tabs.html.erb
        tabs.css

The Ruby API is unchanged. The sidecar stylesheet uses semantic classes and unprefixed @apply, and is imported by source/tailwind/view.css into the existing LesliView stylesheet. Global theme variables remain in LesliAssets.

 Edit this page

Last Update: 2026/11/18