Composite

Tabs

Tab navigation with configurable tab buttons and panel content.

Horizontal (default)

Content Block

Formula Blueprint: Fun Meets Functionality!

The template is a free, customizable and production-ready template for Astro 5.0 + Tailwind CSS.

Nested inside a panel to show richer blocks are supported.

Demo image
horizontal
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
import Content from '@alfadormx/blocks/composite/Content.astro';
---

<Tabs
  items={[{ label: 'Overview' }, { label: 'API' }, { label: 'Examples' }]}
  defaultItemConfig={{ variant: 'ghost', intent: 'neutral' }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  tabList={{
    spacing: { padding: 'p-2', gap: 'gap-2' },
    border: { width: 'border', color: 'border-gray-200', radius: 'rounded-lg' },
  }}
>
  <div slot="panel-0">
    <Content
      container={{
        background: {
          image:
            'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?fit=min&auto=format&w=768&h=768',
          overlayClass: 'bg-base/60 backdrop-blur-xl',
          attachment: 'fixed',
        },
      }}
      headline={{
        tagline: 'Content Block',
        title: 'Formula Blueprint: Fun Meets Functionality!',
        subtitle:
          'The template is a free, customizable and production-ready template for Astro 5.0 + Tailwind CSS.',
      }}
      image={{
        src: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=600&fit=min&auto=format',
        alt: 'Demo image',
      }}
    >
      <p>Nested inside a panel to show richer blocks are supported.</p>
    </Content>
  </div>
  <div slot="panel-1">
    <Content
      container={{
        background: {
          image:
            'https://images.unsplash.com/photo-1469474968028-56623f02e42e?fit=min&auto=format&w=768&h=768',
          overlayClass: 'bg-base/60 backdrop-blur-xl',
          attachment: 'fixed',
        },
      }}
      headline={{
        tagline: 'Content Block',
        title: 'Ship Faster with a Documented API',
        subtitle:
          'Every block ships with typed props and clear examples so you spend less time guessing.',
      }}
      image={{
        src: 'https://images.unsplash.com/photo-1469474968028-56623f02e42e?w=800&h=600&fit=min&auto=format',
        alt: 'Demo image',
      }}
    >
      <p>Nested inside a panel to show richer blocks are supported.</p>
    </Content>
  </div>
  <div slot="panel-2">
    <Content
      container={{
        background: {
          image:
            'https://images.unsplash.com/photo-1507525428034-b723cf961d3e?fit=min&auto=format&w=768&h=768',
          overlayClass: 'bg-base/60 backdrop-blur-xl',
          attachment: 'fixed',
        },
      }}
      headline={{
        tagline: 'Content Block',
        title: 'See It In Action',
        subtitle: 'Explore real compositions built from the same primitives you already know.',
      }}
      image={{
        src: 'https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=800&h=600&fit=min&auto=format',
        alt: 'Demo image',
      }}
    >
      <p>Nested inside a panel to show richer blocks are supported.</p>
    </Content>
  </div>
</Tabs>

Vertical

Content Block

Formula Blueprint: Fun Meets Functionality!

The template is a free, customizable and production-ready template for Astro 5.0 + Tailwind CSS.

Nested inside a panel to show richer blocks are supported.

Demo image
vertical
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
import Content from '@alfadormx/blocks/composite/Content.astro';
---

<Tabs
  items={[{ label: 'Overview' }, { label: 'API' }, { label: 'Examples' }]}
  defaultItemConfig={{ variant: 'ghost', intent: 'neutral' }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  orientation="vertical"
>
  <div slot="panel-0">
    <Content
      container={{
        background: {
          image:
            'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?fit=min&auto=format&w=768&h=768',
          overlayClass: 'bg-base/60 backdrop-blur-xl',
          attachment: 'fixed',
        },
      }}
      headline={{
        tagline: 'Content Block',
        title: 'Formula Blueprint: Fun Meets Functionality!',
        subtitle:
          'The template is a free, customizable and production-ready template for Astro 5.0 + Tailwind CSS.',
      }}
      image={{
        src: 'https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=800&h=600&fit=min&auto=format',
        alt: 'Demo image',
      }}
    >
      <p>Nested inside a panel to show richer blocks are supported.</p>
    </Content>
  </div>
  <div slot="panel-1">
    <Content
      container={{
        background: {
          image:
            'https://images.unsplash.com/photo-1469474968028-56623f02e42e?fit=min&auto=format&w=768&h=768',
          overlayClass: 'bg-base/60 backdrop-blur-xl',
          attachment: 'fixed',
        },
      }}
      headline={{
        tagline: 'Content Block',
        title: 'Ship Faster with a Documented API',
        subtitle:
          'Every block ships with typed props and clear examples so you spend less time guessing.',
      }}
      image={{
        src: 'https://images.unsplash.com/photo-1469474968028-56623f02e42e?w=800&h=600&fit=min&auto=format',
        alt: 'Demo image',
      }}
    >
      <p>Nested inside a panel to show richer blocks are supported.</p>
    </Content>
  </div>
  <div slot="panel-2">
    <Content
      container={{
        background: {
          image:
            'https://images.unsplash.com/photo-1507525428034-b723cf961d3e?fit=min&auto=format&w=768&h=768',
          overlayClass: 'bg-base/60 backdrop-blur-xl',
          attachment: 'fixed',
        },
      }}
      headline={{
        tagline: 'Content Block',
        title: 'See It In Action',
        subtitle: 'Explore real compositions built from the same primitives you already know.',
      }}
      image={{
        src: 'https://images.unsplash.com/photo-1507525428034-b723cf961d3e?w=800&h=600&fit=min&auto=format',
        alt: 'Demo image',
      }}
    >
      <p>Nested inside a panel to show richer blocks are supported.</p>
    </Content>
  </div>
</Tabs>

Tab list layout: row

tabList.layout is independent of orientation. Here a vertical Tabs keeps its tab list beside the panel, while the triggers themselves run in a row.

Overview panel content.

layout-row
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
---

<Tabs
  items={[{ label: 'Overview' }, { label: 'API' }, { label: 'Examples' }]}
  defaultItemConfig={{ variant: 'ghost', intent: 'neutral' }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  orientation="vertical"
  tabList={{ layout: 'row', spacing: { padding: 'p-2', gap: 'gap-2' } }}
>
  <div slot="panel-0">
    <p>Overview panel content.</p>
  </div>
  <div slot="panel-1">
    <p>API panel content.</p>
  </div>
  <div slot="panel-2">
    <p>Examples panel content.</p>
  </div>
</Tabs>

Tab list layout: column

The mirror case: a horizontal Tabs whose triggers are stacked in a column above the panel. Each trigger spans the full width of the tab list.

Overview panel content.

layout-column
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
---

<Tabs
  items={[{ label: 'Overview' }, { label: 'API' }, { label: 'Examples' }]}
  defaultItemConfig={{ variant: 'ghost', intent: 'neutral' }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  tabList={{ layout: 'column', spacing: { padding: 'p-2', gap: 'gap-2' } }}
>
  <div slot="panel-0">
    <p>Overview panel content.</p>
  </div>
  <div slot="panel-1">
    <p>API panel content.</p>
  </div>
  <div slot="panel-2">
    <p>Examples panel content.</p>
  </div>
</Tabs>

Tab list layout: column, content-sized triggers

Set width: 'auto' on defaultItemConfig (or on an item) to keep triggers as wide as their own label instead of filling the tab list.

Overview panel content.

layout-column-auto
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
---

<Tabs
  items={[{ label: 'Overview' }, { label: 'API' }, { label: 'Examples' }]}
  defaultItemConfig={{ variant: 'ghost', intent: 'neutral', width: 'auto' }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  tabList={{ layout: 'column', spacing: { padding: 'p-2', gap: 'gap-2' } }}
>
  <div slot="panel-0">
    <p>Overview panel content.</p>
  </div>
  <div slot="panel-1">
    <p>API panel content.</p>
  </div>
  <div slot="panel-2">
    <p>Examples panel content.</p>
  </div>
</Tabs>

Tab list layout: grid

tabList.layout: 'grid' arranges the triggers as tiles. The column count is read from the width of the tab list’s own container, not the viewport, so the same config adapts inside a narrow panel. tabList.columns applies only in this layout, and the count never drops below two columns. Each tile fills its grid cell, so every tile has the same size.

Grid is meant for orientation="horizontal". In orientation="vertical" the tab list sits in an auto grid track, where a size container has no intrinsic width to measure, so the tile grid collapses; use layout: 'row' or layout: 'column' there.

Overview panel content.

layout-grid
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
---

<Tabs
  items={[
    { label: 'Overview' },
    { label: 'API' },
    { label: 'Examples' },
    { label: 'Themes' },
    { label: 'Layout' },
    { label: 'Tokens' },
  ]}
  defaultItemConfig={{
    variant: 'ghost',
    intent: 'neutral',
    orientation: 'vertical',
    icon: { name: 'heroicons:cube' },
  }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  tabList={{ layout: 'grid', columns: 3 }}
>
  <div slot="panel-0">
    <p>Overview panel content.</p>
  </div>
  <div slot="panel-1">
    <p>API panel content.</p>
  </div>
  <div slot="panel-2">
    <p>Examples panel content.</p>
  </div>
  <div slot="panel-3">
    <p>Themes panel content.</p>
  </div>
  <div slot="panel-4">
    <p>Layout panel content.</p>
  </div>
  <div slot="panel-5">
    <p>Tokens panel content.</p>
  </div>
</Tabs>

Any number of tabs

The panel count follows the item count — there is no cap. Twelve items render twelve triggers and twelve panel-0 … panel-11 slots, each with its own tabpanel id and ARIA wiring.

Panel one.

many
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
---

<Tabs
  items={[
    { label: 'One' },
    { label: 'Two' },
    { label: 'Three' },
    { label: 'Four' },
    { label: 'Five' },
    { label: 'Six' },
    { label: 'Seven' },
    { label: 'Eight' },
    { label: 'Nine' },
    { label: 'Ten' },
    { label: 'Eleven' },
    { label: 'Twelve' },
  ]}
  defaultItemConfig={{ variant: 'ghost', intent: 'neutral' }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  tabList={{ layout: 'grid', columns: 4 }}
>
  <div slot="panel-0">
    <p>Panel one.</p>
  </div>
  <div slot="panel-1">
    <p>Panel two.</p>
  </div>
  <div slot="panel-2">
    <p>Panel three.</p>
  </div>
  <div slot="panel-3">
    <p>Panel four.</p>
  </div>
  <div slot="panel-4">
    <p>Panel five.</p>
  </div>
  <div slot="panel-5">
    <p>Panel six.</p>
  </div>
  <div slot="panel-6">
    <p>Panel seven.</p>
  </div>
  <div slot="panel-7">
    <p>Panel eight.</p>
  </div>
  <div slot="panel-8">
    <p>Panel nine.</p>
  </div>
  <div slot="panel-9">
    <p>Panel ten.</p>
  </div>
  <div slot="panel-10">
    <p>Panel eleven.</p>
  </div>
  <div slot="panel-11">
    <p>Panel twelve.</p>
  </div>
</Tabs>

Sticky tab list

tabList.sticky keeps the triggers in view while the panels scroll. Under a sticky Header the tab list stops directly below it: Header publishes its height as --scroll-padding-top and the tab list’s default top reads it, falling back to 0 when no Header is sticky. The box below is its own scroll box under the docs page’s sticky Header, so it cancels the offset with top-0; scroll it and the triggers stay at the top.

The flag adds sticky top-(--scroll-padding-top,0px) z-10 bg-background, plus self-start in vertical orientation. In grid layout they land on the @container wrapper, so cancel them from tabList.wrapperClass; in row and column layouts they land on the tab list, so cancel them from tabList.class. Use top-0 when the tabs sit in their own scroll box under a page-level sticky Header (md:top-0 if that box only exists from a breakpoint up), and swap bg-background for the section’s background, such as bg-surface, to avoid a visible band.

Overview paragraph 1.

Overview paragraph 2.

Overview paragraph 3.

Overview paragraph 4.

Overview paragraph 5.

Overview paragraph 6.

Overview paragraph 7.

Overview paragraph 8.

Overview paragraph 9.

Overview paragraph 10.

Overview paragraph 11.

Overview paragraph 12.

sticky
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
---

<Tabs
  items={[{ label: 'Overview' }, { label: 'API' }, { label: 'Examples' }]}
  defaultItemConfig={{ variant: 'ghost', intent: 'neutral' }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  tabList={{
    layout: 'grid',
    columns: 3,
    sticky: true,
    wrapperClass: 'top-0',
  }}
>
  <div slot="panel-0">
    {Array.from({ length: 12 }, (_, i) => (
      <p>Overview paragraph {i + 1}.</p>
    ))}
  </div>
  <div slot="panel-1">
    {Array.from({ length: 12 }, (_, i) => (
      <p>API paragraph {i + 1}.</p>
    ))}
  </div>
  <div slot="panel-2">
    {Array.from({ length: 12 }, (_, i) => (
      <p>Examples paragraph {i + 1}.</p>
    ))}
  </div>
</Tabs>

Sticky row tab list

sticky works in every layout; outside grid the defaults land on the tab list itself, as described above.

Overview paragraph 1.

Overview paragraph 2.

Overview paragraph 3.

Overview paragraph 4.

Overview paragraph 5.

Overview paragraph 6.

Overview paragraph 7.

Overview paragraph 8.

Overview paragraph 9.

Overview paragraph 10.

Overview paragraph 11.

Overview paragraph 12.

sticky-row
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
---

<Tabs
  items={[{ label: 'Overview' }, { label: 'API' }, { label: 'Examples' }]}
  defaultItemConfig={{ variant: 'ghost', intent: 'neutral' }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  tabList={{ layout: 'row', sticky: true, class: 'top-0' }}
>
  <div slot="panel-0">
    {Array.from({ length: 12 }, (_, i) => (
      <p>Overview paragraph {i + 1}.</p>
    ))}
  </div>
  <div slot="panel-1">
    {Array.from({ length: 12 }, (_, i) => (
      <p>API paragraph {i + 1}.</p>
    ))}
  </div>
  <div slot="panel-2">
    {Array.from({ length: 12 }, (_, i) => (
      <p>Examples paragraph {i + 1}.</p>
    ))}
  </div>
</Tabs>

Panel styling

panelClass lands on every panel. Display utilities such as flex are safe: inactive panels stay hidden.

Overview paragraph one.

Overview paragraph two.

panel-class
---
import Tabs from '@alfadormx/blocks/composite/Tabs.astro';
---

<Tabs
  items={[{ label: 'Overview' }, { label: 'API' }]}
  defaultItemConfig={{ variant: 'ghost', intent: 'neutral' }}
  activeItemConfig={{ variant: 'solid', intent: 'primary' }}
  panelClass="flex flex-col gap-4 p-4 bg-surface rounded-lg"
>
  <div slot="panel-0">
    <p>Overview paragraph one.</p>
    <p>Overview paragraph two.</p>
  </div>
  <div slot="panel-1">
    <p>API paragraph one.</p>
    <p>API paragraph two.</p>
  </div>
</Tabs>

API Reference

PropTypeDefaultDescription
itemsOmit<ButtonProps, 'id' | 'name'>[]—List of tab entries; each item is a Button config rendered as a tab trigger, and its index maps to a `panel-{n}` slot for content. Any number of tabs is supported — the panel count follows the item count with no upper bound. `id` and `name` are omitted because Tabs assigns trigger ids. A field set on an item applies in every state; style states through `defaultItemConfig` / `activeItemConfig`.
defaultItemConfigLayerConfig<ButtonProps>—Button config merged under every tab, in both states, before the item's own values.
activeItemConfigLayerConfig<ButtonProps>—Button config merged over `defaultItemConfig` on the active tab only.
orientation'horizontal' | 'vertical''horizontal'Layout direction of the tab list and content: 'horizontal' stacks tabs in a row above the panel, 'vertical' places them side by side in a grid (default: 'horizontal').
containerContainerProps—Config passed to the wrapping Container block that surrounds the whole Tabs component.
panelClassstring—Custom classes for every tab panel (the element with role="tabpanel"); display utilities such as `flex` are safe, inactive panels stay hidden. Configurator panel heading and control are its direct children.
tabListOmit<CellProps, 'spacing'> & { spacing?: SpacingConfig; /** How the triggers are arranged among themselves; independent of `orientation`. Unset derives from `orientation` ('vertical' -> column, otherwise row). In 'grid' and 'column' the triggers fill the tab list (grid: whole cell; column: full width); set `width: 'auto'` on `defaultItemConfig`, `activeItemConfig` or an item to opt out. Setting `align` on a trigger disables the fill. */ layout?: 'row' | 'column' | 'grid'; /** Number of trigger columns at the widest step; applies only when `layout` is 'grid', ignored otherwise (default: 2). Steps down by container width, never below 2. */ columns?: 2 | 3 | 4; /** Sticks the tab list while its scroll container scrolls, directly below a sticky Header (reads `--scroll-padding-top`, falls back to `0px`). Adds `sticky top-(--scroll-padding-top,0px) z-10 bg-background`, plus `self-start` in vertical orientation; cancel any of them from `wrapperClass` (grid) or `class` (row, column), e.g. `top-0` when the tab list sits in its own scroll box under a page-level sticky Header (default: false). */ sticky?: boolean; /** Classes on the `@container` wrapper around the tab list, rendered only when `layout` is 'grid'. With `sticky`, the wrapper is what sticks, so cancel its defaults here. */ wrapperClass?: string; }—Styling and arrangement config for the tablist wrapper (the element with role="tablist"): background, spacing, border, an extra class name, plus `layout` (how the triggers are arranged among themselves), `columns` (grid layout only) and `sticky`.

Panel content is any element placed in the matching panel-0, panel-1, … slots — see the Horizontal/Vertical examples above. Style every panel with panelClass.

Accessibility

  • The tab list is a single tab stop: Tab lands on the active tab and leaves to the panel content.
  • Arrow keys follow the tab list’s axis: Left/Right for row and grid layouts, Up/Down for column. Left/Right are swapped in right-to-left documents.
  • Home and End jump to the first and last tab.
  • Focus wraps at both ends, and moving focus activates the tab.
  • Disabled tabs are skipped.
  • The layout sets aria-orientation on the tab list; grid layouts are navigated as a single row in reading order.