Page tabs
The PageTabs component under test: rhythm against the page's spacing, deep links between tabs, closed-tab crawler check and a row of nine tabs for overflow.
Using it
Each tab is an id, a label and its content. The ids end up in the URL hash.
import { PageTabs } from "@/components/site/page-tabs";
<PageTabs
tabs={[
{ id: "overview", label: "Overview", children: <Overview /> },
{ id: "details", label: "Details", children: <Details /> },
]}
/>Try it
The first tab, open by default. Switch tabs and watch the address bar: the hash follows.
Reload the page on another tab and it opens there.
A heading
A paragraph straight after the heading, then a list.
- First item
- Second item
const sample = "a code block";A last paragraph.
These are plain anchors, so the browser fires a hash change that the tabs listen for: jump to Basics, jump to Rhythm, and a hash that isn't a tab, which is ignored.
A router link to a hash would change the URL without that event, so use plain anchors for links between tabs.
Zebra-4 marker: this sentence is in a tab that isn't showing at first, and it's still in the page source, so crawlers and find-in-page can see it.
The same blocks outside the tabs
For comparison with the Rhythm tab: the gaps should match.
A heading
A paragraph straight after the heading, then a list.
- First item
- Second item
const sample = "a code block";A last paragraph.
Many tabs
Narrow the window: the bar should scroll sideways instead of wrapping or overflowing the page.
This is the one tab. With this many, the bar has to scroll sideways on a phone.
This is the two tab. With this many, the bar has to scroll sideways on a phone.
This is the three tab. With this many, the bar has to scroll sideways on a phone.
This is the four tab. With this many, the bar has to scroll sideways on a phone.
This is the five tab. With this many, the bar has to scroll sideways on a phone.
This is the six tab. With this many, the bar has to scroll sideways on a phone.
This is the seven tab. With this many, the bar has to scroll sideways on a phone.
This is the eight tab. With this many, the bar has to scroll sideways on a phone.
This is the nine tab. With this many, the bar has to scroll sideways on a phone.
Things to check
Crawlers.The Zebra-4 sentence should be in the page source even while its tab is closed.Rhythm.The blocks in the tab and the same blocks below should have the same gaps.Deep links.Load the page with#rhythmon the end and it should open on that tab. Back and forward shouldn't break it.Two sets.Switching the lower set must not change the upper one.Hidden headings.A heading inside a closed tab can't be scrolled to, so a contents link to it does nothing. Worth remembering before putting headings in tabs.
Related
- UI stress test
Nested components stacked inside each other, like bold and code inside links and tables inside lists, to find where the styles break.
- Table stress
Tables with very wide cells, long unbroken words and many columns, to check how they scroll and wrap.
- Code stress test
Absurdly long identifiers, strings, paths, and files in inline code and code blocks.
- Code blocks
The VS Code-style code block: snippets, multi-file tabs, explorer, wrap, copy.