Ballmac UI home

Section Tabs

Sticky in-page tabs that follow the reader's section, slide an indicator to it, keep the active tab in view on narrow screens and scroll to a section on click.

Overview

Section 1. The tab bar sticks to the top, follows your position and scrolls to a section when you choose its tab.

Features

Section 2. The tab bar sticks to the top, follows your position and scrolls to a section when you choose its tab.

Pricing

Section 3. The tab bar sticks to the top, follows your position and scrolls to a section when you choose its tab.

FAQ

Section 4. The tab bar sticks to the top, follows your position and scrolls to a section when you choose its tab.

Installation

$ pnpm dlx shadcn@latest add @ballmac/section-tabs

Usage

import { SectionTabs } from "@/components/ballmac/section-tabs"

The full example is in the Code tab above.

Examples

Pill, narrow

Details

Narrow screens scroll the tabs sideways and keep the active one centered.

Specs

Narrow screens scroll the tabs sideways and keep the active one centered.

Reviews

Narrow screens scroll the tabs sideways and keep the active one centered.

Shipping

Narrow screens scroll the tabs sideways and keep the active one centered.

Returns

Narrow screens scroll the tabs sideways and keep the active one centered.

Support

Narrow screens scroll the tabs sideways and keep the active one centered.

API reference

PropTypeDefault
sections*

Sections in page order.

SectionTab[]—
label

Accessible name of the navigation landmark.

string—
offset

Pixels of space to keep above a section after scrolling to it (your sticky header plus this bar).

number72
container

A scrollable element to watch and scroll instead of the page.

ScrollContainer—
variant

Indicator style.

"underline" | "pill""underline"
sticky

Stick to the top of the page (or container) while scrolling.

booleantrue
stickyTop

Distance from the top when sticky.

number0

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
EnterScrolls to the section and updates the URL hash
TabReal links; middle-click and copy link work
Screen readersCurrent section has aria-current=location

Use with AI

sections: {id,label} matching element ids in the page. offset is the space to leave for this bar and any header. variant underline or pill. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Section Tabs (@ballmac/section-tabs) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Long product, pricing and docs pages
  • Anchored sections of a settings page

Not for

  • Switching views without scrolling; use tabs
  • Vertical page outlines; use table-of-contents

Registry JSON: https://ui.ballmac.com/r/section-tabs.json

Credits

Free to use in personal and commercial projects.