SectionBar
A sticky row of chips linking to the sections of one long page, such as a menu's categories or a product's specs.
Popular
- Lantern bowl
- Spicy tantan
- Karaage
- Gyoza
Ramen
- Lantern bowl
- Spicy tantan
- Garden shio
Small plates
- Gyoza
- Karaage
- Edamame
Sweets
- Black sesame soft serve
- Yuzu sorbet
View code
<SectionBar
id="menu-bar"
label="Menu categories"
top="4rem"
items={sections.map((section) => ({ id: section.id, label: section.name, count: section.items.length }))}
/>
{sections.map((section) => (
<section id={section.id} style={`scroll-margin-top: calc(4rem + ${SECTION_BAR_BLOCK_SIZE})`}>
<h2>{section.name}</h2>
</section>
))}Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add section-barUsage
import { SectionBar } from "@sdxc/ui";Renders the bar: a <nav> holding a sideways-scrolling row of chip links, the first one
marked current until the island reads the scroll.
Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The bar's id, unique on the page; its island finds the bar by it. |
label | string | Yes | The landmark's name, such as "Menu categories". |
items | Item[] | Yes | |
top | string | No | Where the bar sticks, as a CSS length from the top of the viewport, such as the height of a sticky top bar above it. Each section gives itself a scroll-margin-top of at least this plus the bar's own height, so a jump lands below the bar. |
Also accepts everything in Omit<TagProps<"nav">, "children">.