Appica UIUI 1.0.0

Table of Content (TOC)

A scroll-spy navigation sidebar that tracks the current section as the page scrolls.

Getting started

A longer opening paragraph so the first section is tall enough to fill the panel on its own, which means only the first link is highlighted before you start scrolling. Each component ships from its own subpath, so your bundler only pulls in what you actually use and tree-shaking does the rest. There is nothing global to configure beyond the theme layer — components bring their own styles, and a fresh install renders correctly straight away. A component behaves identically on the server and the client, so you can drop it anywhere in a React tree without a "use client" boundary unless your own code needs one. Drive the article up and down and watch the active link follow along as each later section comes into view.

Theming

A longer paragraph so each section is tall enough to scroll through the viewport, which means only the heading currently in view stays highlighted rather than all of them at once.

Accessibility

A longer paragraph so each section is tall enough to scroll through the viewport, which means only the heading currently in view stays highlighted rather than all of them at once.

Usage

Toc is an "on this page" sidebar that watches the document and highlights the link whose heading is currently in view. Each TocLink's href points at a heading's id (href="#installation"<h2 id="installation">); the component registers those targets, observes them with an IntersectionObserver, and marks the visible ones data-active. When several headings share the screen the indicator stretches to cover the whole span, and aria-current lands on the topmost one.

It's purely compositional — no list data is passed in. Lay out the items yourself (typically generated from your page's headings) and set each link's depth to match its heading level so deeper headings indent. Everything is driven by the real DOM, so the headings just need matching ids.

Because scroll-spy needs a scroll position to track, the live examples below put the article in a self-contained scrolling panel — scroll inside it to watch the active link follow along. They also intercept link clicks to scroll that panel rather than the page; on a real page where the TOC tracks the document, you'd skip that and let the anchor jump the page natively.

Examples

Default

A flat list of top-level headings. As you scroll the article, the link tracking the visible heading lights up and the indicator slides to it.

Nested headings

Give each TocLink a depth (2–6) matching its heading level and deeper entries indent automatically — the typical <h2>/<h3> outline. The active indicator runs down the shared left rail regardless of depth.

With icons

TocLink takes arbitrary children, so you can prefix each entry with an icon. Set the link to flex and size the SVG; the icon inherits the link's color, so it brightens along with the label when active.

Scroll offset

On a real page with a sticky header, headings become "current" a little too early — they're technically in view but hidden behind the header. Pass rootMargin to Toc to shrink the observer's viewport from the top by the header's height, so a heading only counts as active once it clears it:

The value is a standard IntersectionObserver rootMargin string (top right bottom left). A negative top inset pulls the active boundary down below your header.

TocLink is built on Base UI's useRender, so you can project it onto your framework's link with render while keeping the scroll-spy wiring and active styling:

RTL

Every Appica UI component supports right-to-left layouts out of the box. Set the dir attribute on a container (commonly your <html> element) so CSS logical properties resolve correctly, and wrap your tree in DirectionProvider so direction-aware behavior follows the same direction.

The list's rail and active indicator move to the right edge and the depth indentation flips, since both are built from CSS logical properties. For setup details and caveats, see the RTL guide.

البداية

ثبّت الحزمة بمدير الحزم المفضّل لديك واستورد المكوّن الذي تحتاجه من مساره الخاص. لا يوجد شيء عام لإعداده، فكل مكوّن يجلب أنماطه الخاصة ويعمل فور إدراجه في الصفحة دون أي تهيئة إضافية. كما أن إزالة الشيفرة غير المستخدمة تبقي الحزمة صغيرة، ولا حاجة لحقن أنماط في زمن التشغيل. ويعمل المكوّن بالطريقة نفسها على الخادم والعميل، فيمكنك استخدامه في أي مكان داخل شجرة React دون الحاجة إلى حدّ "use client" ما لم تتطلبه شيفرتك. والقيم الافتراضية المعقولة تعني أنه يظهر بشكل صحيح فورًا، ويمكنك تجاوز أي خيار عبر الخصائص أو أسماء الأصناف. وبمجرد أن تعتاد على مكوّن واحد، تتبع البقية الواجهة نفسها القائمة على التركيب، فلا يبقى الكثير لتتعلمه.

السمات

تُدار الألوان والزوايا والحركة عبر متغيرات CSS يمكنك تجاوزها في أي مكان من الشجرة. الوضعان الفاتح والداكن مجرد مجموعتين من المتغيرات نفسها، لذا فإن تبديل السمة هو صنف واحد على العنصر الأب. وكل القيم تُحلّ في زمن التشغيل دون خطوة بناء.

إمكانية الوصول

تتبع المكوّنات أنماط WAI-ARIA افتراضيًا، فدعم لوحة المفاتيح وقارئات الشاشة متاح تلقائيًا. تُدار حالة التركيز والأدوار والمعالم المُسمّاة من قبل المكوّنات نفسها. يبقى عليك تسمية كل نسخة، أما الربط الداخلي فمُنجَز.

من اليمين لليسار

الخصائص المنطقية تجعل كل مكوّن ينعكس بسلاسة في الوضع من اليمين لليسار. الحشو والحدود وترتيب التركيز وموضع النوافذ المنبثقة كلها تنقلب لتتبع اتجاه القراءة. وتبديل التطبيق بأكمله هو سمة واحدة مع مزوّد الاتجاه.

API reference

Each part forwards every remaining prop to its underlying element (nav, ul, li, a). The tables below list the Appica additions and the most common props.

Toc

The navigation landmark and scroll-spy provider. Renders a <nav aria-label="Table of contents">.

TocList

The list of entries, carrying the shared rail and sliding active indicator. Renders a <ul role="list">.

TocItem

One entry's <li> wrapper.

A link to one heading. Registers its target for scroll-spy and reflects the active state. Built on Base UI's useRender; renders an <a> unless you project it with render.

The link exposes data-active while its heading is in view and aria-current="true" on the topmost active link — both available for styling.

Accessibility

  • Toc renders a <nav> with a default aria-label="Table of contents"; override it (e.g. "On this page") to suit the surrounding page. The list is a role="list" of plain links.
  • The topmost in-view link carries aria-current="true", so assistive tech announces the reader's current position.
  • Links are ordinary anchors, fully keyboard-focusable, and activating one jumps to its heading — pair headings with scroll-mt-* so they aren't hidden under a sticky header on arrival.
  • The active indicator and link transitions honour prefers-reduced-motion.
  • Scroll-spy is presentational: it only updates data-active/aria-current, never moving focus or scrolling on its own.

© 2026 Appica UI. A free component library, crafted by the Appica team.