NavigationTabs
Searchastronomic.dev# Tabs
To show one of a few short, related texts at a time, like the stages of a project, without a long page.
Interactive: React island.
## Usage
```astro
import Tabs from "@astronomic/ui-pro/components/Tabs.astro";
```
## Examples
### Project stages
```astro
---
import Tabs from "@astronomic/ui-pro/components/Tabs.astro";
const stages = [
{
value: "discovery",
label: "Discovery",
content: [
"We start with a workshop: your team, your clients, and what the site must do for both.",
"You get a short brief back within a week, with the pages we plan and why.",
],
},
{ value: "design", label: "Design", content: "We design the key pages with your real content, and change them with you until they fit." },
{ value: "build", label: "Build", content: "We build fast, accessible pages that your team can edit, and test them on phones and screen readers." },
{ value: "launch", label: "Launch", content: "We move your content, set up redirects, train your editors and stay on hand for the first month." },
];
---
<Tabs items={stages} label="Project stages" />
```
## Props
### Tabs
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` | `TabItem[]` | None | Required. TabItem is { value, label, content }. value is unique, label is the tab's text, and content is one paragraph or a list of paragraphs. |
| `defaultValue` | `string` | None | The value open on load. Without it, the first item is open. |
| `label` | `string` | None | Required. The tab list's accessible name, like "Project stages". |
| `class` | `string` | None | More classes on the root, merged with cn(), so yours win on conflicts. |
## Accessibility
| Key | Action |
| --- | --- |
| Tab | Moves focus to the selected tab, then into its panel |
| Arrow Right and Arrow Left | Move to the next or previous tab and show its panel; they wrap at the ends |
| Home and End | Move to the first or the last tab |
- A tablist named by label; each tab is a tab with aria-selected, and each panel is a tabpanel named by its tab.
- The server renders every label and every panel, closed ones hidden, so all the text is in the page before the island hydrates. It hydrates once the browser is idle; until then the tabs do not answer the keyboard.
- For long content that people compare, use headings on one page instead of tabs.
Tabs
ProTo show one of a few short, related texts at a time, like the stages of a project, without a long page.
- File
- Tabs.astro
- Group
- Navigation
- Kind
- Interactive: React island
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Project stages
We start with a workshop: your team, your clients, and what the site must do for both.
You get a short brief back within a week, with the pages we plan and why.
We design the key pages with your real content, and change them with you until they fit.
We build fast, accessible pages that your team can edit, and test them on phones and screen readers.
We move your content, set up redirects, train your editors and stay on hand for the first month.
Force statemain.astro
examples/tabs/main.astro
---
import Tabs from "@astronomic/ui-pro/components/Tabs.astro";
const stages = [
{
value: "discovery",
label: "Discovery",
content: [
"We start with a workshop: your team, your clients, and what the site must do for both.",
"You get a short brief back within a week, with the pages we plan and why.",
],
},
{ value: "design", label: "Design", content: "We design the key pages with your real content, and change them with you until they fit." },
{ value: "build", label: "Build", content: "We build fast, accessible pages that your team can edit, and test them on phones and screen readers." },
{ value: "launch", label: "Launch", content: "We move your content, set up redirects, train your editors and stay on hand for the first month." },
];
---
<Tabs items={stages} label="Project stages" />Minimal · Light