Tabs: line, boxed, pill, text, segmented and nav (the lu-tb family), plus the
classic underline tabs with count badges (lu-tabs), horizontal or vertical.
<.tabs id="profile" selected="home" on_change="select_tab">
<:tab name="home">Home</:tab>
<:tab name="profile" count={4}>Profile</:tab>
<:panel name="home">...</:panel>
<:panel name="profile">...</:panel>
</.tabs>Switching happens in the browser through the hook LedgerUI.Tabs
(priv/static/ledger_ui/hooks/tabs.js): click, ←/→ (↑/↓ when vertical), Home and End, no
round trip. A choice made in the browser survives patches; when the server changes
selected the server wins. on_change (an event name or a %JS{}) is pushed with
%{"id" => id, "value" => name, "tab" => name}, and every selection dispatches a
bubbling ledger:change event with detail: {id, value, tab}.
Tabs with patch, navigate or href are links (aria-current="page" when selected).
Notes on the markup
The server renders the ARIA: role="tablist" (+ aria-orientation when vertical), tab buttons
with role="tab", aria-selected, the roving tabindex and aria-controls (when there is a
panel); the hook only updates aria-selected/tabindex/on as the selection changes. color has no default (nil renders no c-* class, which is the primary look);
pass color="primary" to emit c-primary. Panels are role="tabpanel" boxes that the hook
shows/hides; there is no sliding transition in the stylesheet, transition is exposed as
data-transition for apps that style it.
Additive tab attrs: role (pass nil to drop it) and count_tone (acc, neg...).
Summary
Functions
Attributes
id(:string) (required)selected(:string) - Defaults tonil.variant(:string) - Defaults to"line". Must be one of"line","boxed","pill","text","segmented","nav", or"classic".size(:string) - Defaults to"md". Must be one of"xs","sm", or"md".color(:string) - Defaults tonil.Must be one ofnil,"primary", or"neutral".orientation(:string) - Defaults to"horizontal". Must be one of"horizontal", or"vertical".bordered(:boolean) - Defaults tofalse.overlap(:boolean) - Defaults tofalse.grow(:boolean) - Defaults tofalse.transition(:string) - Defaults to"left". Must be one of"left","up", or"none".on_change(:any) - Defaults tonil.soon_label(:string) - Defaults to"Em breve".target(:any) - Defaults tonil.list_class(:any) - Defaults tonil.panels_class(:any) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
panel- Accepts attributes:name(:string) (required)class(:any)
tab(required) - Accepts attributes:name(:string) - Names the tab forselectedand its panel (the position when missing).active(:boolean) - The tab that is selected at first, whenselectedis not given.disabled(:boolean)count(:any)overdue(:boolean)count_tone(:string)patch(:string)navigate(:string)href(:string)replace(:boolean)soon(:boolean)role(:any)aria-selected(:string)title(:string)id(:string)class(:any)phx-click(:any)phx-target(:any)phx-value-id(:any)phx-value-name(:any)