# `LedgerUI.Components.Tabs`
[🔗](https://github.com/devaction-labs/ledger_ui/blob/v0.2.0/lib/ledger_ui/components/tabs.ex#L1)

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`...).

# `tabs`

## Attributes

* `id` (`:string`) (required)
* `selected` (`:string`) - Defaults to `nil`.
* `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 to `nil`.Must be one of `nil`, `"primary"`, or `"neutral"`.
* `orientation` (`:string`) - Defaults to `"horizontal"`. Must be one of `"horizontal"`, or `"vertical"`.
* `bordered` (`:boolean`) - Defaults to `false`.
* `overlap` (`:boolean`) - Defaults to `false`.
* `grow` (`:boolean`) - Defaults to `false`.
* `transition` (`:string`) - Defaults to `"left"`. Must be one of `"left"`, `"up"`, or `"none"`.
* `on_change` (`:any`) - Defaults to `nil`.
* `soon_label` (`:string`) - Defaults to `"Em breve"`.
* `target` (`:any`) - Defaults to `nil`.
* `list_class` (`:any`) - Defaults to `nil`.
* `panels_class` (`:any`) - Defaults to `nil`.
* `class` (`:any`) - Defaults to `nil`.
* Global attributes are accepted.
## Slots

* `panel` - Accepts attributes:

  * `name` (`:string`) (required)
  * `class` (`:any`)
* `tab` (required) - Accepts attributes:

  * `name` (`:string`) - Names the tab for `selected` and its panel (the position when missing).
  * `active` (`:boolean`) - The tab that is selected at first, when `selected` is 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`)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
