Rendered by React 19.3.1
Loading React…import { Tabs } from '@hamur/react/tabs'
export default function TabsExample() {
return (
<Tabs.Root className="tabs" defaultValue="overview">
<Tabs.List className="tabs-list" aria-label="Workspace">
<Tabs.Tab className="tab" value="overview">
Overview
</Tabs.Tab>
<Tabs.Tab className="tab" value="projects">
Projects
</Tabs.Tab>
<Tabs.Tab className="tab" value="billing" disabled>
Billing
</Tabs.Tab>
<Tabs.Tab className="tab" value="account">
Account
</Tabs.Tab>
<Tabs.Indicator className="tabs-indicator" />
</Tabs.List>
<Tabs.Panel className="tabs-panel" value="overview">
Workspace stats and activity.
</Tabs.Panel>
<Tabs.Panel className="tabs-panel" value="projects">
Milestones and deadlines.
</Tabs.Panel>
<Tabs.Panel className="tabs-panel" value="billing">
Invoices and plans.
</Tabs.Panel>
<Tabs.Panel className="tabs-panel" value="account">
Profile and preferences.
</Tabs.Panel>
</Tabs.Root>
)
}
457Tests passing in React · 0 failing
16.0 KiBSize
Not measured yetMemory
Not measured yetSpeed
Installation
npm i @hamur/react
Not on npm yet. The package goes out under the chosen name.
Anatomy
Import the component and assemble its parts:
<Tabs.Root>
<Tabs.List>
<Tabs.Tab />
<Tabs.Indicator />
</Tabs.List>
<Tabs.Panel />
</Tabs.Root>
Examples
Animated Panels
Panels slide in from the side given by data-activation-direction.
TabsAnimatedPanels.tsx
import { Tabs } from '@hamur/react/tabs'
export default function TabsAnimatedPanelsExample() {
return (
<Tabs.Root className="tabs" defaultValue="overview">
<Tabs.List className="tabs-list">
<Tabs.Tab className="tab" value="overview">
Overview
</Tabs.Tab>
<Tabs.Tab className="tab" value="projects">
Projects
</Tabs.Tab>
<Tabs.Tab className="tab" value="account">
Account
</Tabs.Tab>
<Tabs.Indicator className="tabs-indicator" />
</Tabs.List>
<div className="tabs-panel-viewport">
<Tabs.Panel className="tabs-panel tabs-panel-slide" value="overview">
<p>Workspace stats and activity.</p>
</Tabs.Panel>
<Tabs.Panel className="tabs-panel tabs-panel-slide" value="projects">
<p>Milestones and deadlines.</p>
</Tabs.Panel>
<Tabs.Panel className="tabs-panel tabs-panel-slide" value="account">
<p>Profile and preferences.</p>
</Tabs.Panel>
</div>
</Tabs.Root>
)
}
API reference
12 props across 5 parts, in React syntax. className, style, render are listed once, under Shared props.
IndicatorTabs.Indicator
A visual indicator that can be styled to match the position of the currently active tab. Renders a <span>.
ListTabs.List
Groups the individual tab buttons. Renders a <div>.
PanelTabs.Panel
A panel displayed when the corresponding tab is active. Renders a <div>.
RootTabs.Root
Groups the tabs and the corresponding panels. Renders a <div>.
TabTabs.Tab
An individual interactive tab button that toggles the corresponding panel. Renders a <button>.
Shared props
Every part that renders an element takes these.
Keyboard and accessibility
Keyboard
Accessibility
Focus order
- The list is one tab stop: the active tab.
- Arrow keys,
Home and End move between tabs; Enter or Space activates one unless activateOnFocus is on. - The active Panel has
tabindex="0", so the next Tab reaches it when it has no focusable content.