SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

On this page

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.

Ramen

  • Lantern bowl
  • Spicy tantan
  • Garden shio

Small plates

  • Gyoza
  • Karaage
  • Edamame

Sweets

  • Black sesame soft serve
  • Yuzu sorbet
View code
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add section-bar

Usage

typescript
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.

PropTypeRequiredDescription
idstringYesThe bar's id, unique on the page; its island finds the bar by it.
labelstringYesThe landmark's name, such as "Menu categories".
itemsItem[]Yes
topstringNoWhere 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">.

@sdxc/ui

Can’t find it? Contact us