Marketing sectionsIndexTable
Searchastronomic.dev# IndexTable
To build your own ruled table of short facts, such as awards, press or open roles. For a ready layout, use IndexTableStacked or IndexTableSplit.
Static: no JavaScript.
## Usage
```astro
import IndexTable from "@astronomic-dev/ui/components/IndexTable.astro";
```
## Examples
### Slots
The section is a shell: the eyebrow, the heading and the text always show in that order, then the ruled table. The first column is in heading type, the others muted; an end column (a year, a count) sits at the end. From a 36rem container it is a table; below that each row is two lines. IndexTableStacked and IndexTableSplit are recipes built on it.
```astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import IndexTable from "@astronomic-dev/ui/components/IndexTable.astro";
const columns = [
{ key: "family", label: "Family" },
{ key: "tier", label: "Tier" },
{ key: "parts", label: "Parts", align: "end" as const },
];
const rows = [
{ cells: { family: "Navbar", tier: "Free", parts: "6" } },
{ cells: { family: "Features", tier: "Free", parts: "6" } },
{ cells: { family: "Marquee", tier: "Free", parts: "5" } },
{ cells: { family: "Pricing", tier: "Pro", parts: "4" } },
{ cells: { family: "Bento", tier: "Pro", parts: "4" } },
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<IndexTable heading="The largest families" text="Each family is a shell and the recipes built on it, with the parts they share." columns={columns} rows={rows}>
<Badge slot="eyebrow">Astronomic UI</Badge>
</IndexTable>
</div>
```
## Props
### IndexTable
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `heading` | `string` | None | The section heading, in the section role in display type. It names the section and the table. Without it there is no section and no header: a plain <div> holds only the table, named by caption. |
| `emphasis` | `boolean` | `false` | Turn one *phrase* in the heading into <em>: exactly two asterisks around text with no space inside. Off by default, so the heading shows as typed. |
| `mark` | `string` | None | A short mark after the heading, such as "(12)", in small muted type, outside the heading. Shown only with a heading. |
| `markLabel` | `string` | None | What the mark says to a screen reader, such as "12 awards": the mark is then hidden from screen readers and this is read in its place. |
| `text` | `string` | None | One or two sentences under the heading, in the lead role, muted. Shown only with a heading. |
| `headingTag` | `"h2" \| "h3" \| "h4"` | `"h2"` | The heading element. |
| `caption` | `string` | None | The table's name when there is no heading, in a visually hidden <caption>. With a heading too, the caption names the table and the heading the section. One of heading or caption is required: without either the build stops. |
| `columns` | `IndexColumn[]` | None | Required. The columns, in order: { key, label, align? }. key picks each row's cell; label is the column header; align "end" sets a year or a count at the end, in figures of one width, on the first line of the row on a phone. An empty list stops the build. |
| `rows` | `IndexRow[]` | None | Required. The rows, in order: { cells, href? }. cells holds each row's text by column key; a column with no cell shows an empty one, and keys that are not columns are left out. With href the first cell's text is a link to that page. An empty list stops the build. |
| `align` | `"start" \| "center"` | `"start"` | For recipes. The alignment of the header (SectionHead) only. |
| `contentClass` | `string` | None | For recipes. Classes for the row that holds the header and the table. It sits inside the index-table container, so its classes can query it (@4xl/index-table:...). |
| `headerClass` | `string` | None | For recipes. Classes for the header (the eyebrow, the heading and the text). |
| `tableClass` | `string` | None | For recipes. Classes for the <table>. |
| `class` | `string` | None | More classes for the root (the <section>, or the <div> without a heading), merged with cn(), so yours win on conflicts. The root is a named size container (inline-size containment): in a shrink-to-fit parent it collapses, so give it a width there. |
| Slot | Description |
| --- | --- |
| `eyebrow` | A short line above the heading, such as a Badge. Shown only with a heading. |
Any other attribute goes on the <section>, or on the <div> without a heading.
## Accessibility
- It is a real <table> with explicit roles on the table, its rows, its column headers and its cells, so its meaning holds on a phone, where the rows are laid out as two lines.
- With a heading it is a region named by it: a <section> whose heading id is unique on the page, and the table is labeled by the heading. Without one, the table is named by its caption (visually hidden). One of the two is required.
- The header row is visually hidden on a phone, but a screen reader still reads each cell with its column header.
- With href, the first cell's text is the row's one link, named by that text, at least 44px tall on touch screens, with the kit's focus ring.
- A year or a count (align "end") sits at the end of its row in figures of one width.
IndexTable
FreeTo build your own ruled table of short facts, such as awards, press or open roles. For a ready layout, use IndexTableStacked or IndexTableSplit.
- File
- IndexTable.astro
- Group
- Marketing sections
- Kind
- Static: no JavaScript
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
Slots
The section is a shell: the eyebrow, the heading and the text always show in that order, then the ruled table. The first column is in heading type, the others muted; an end column (a year, a count) sits at the end. From a 36rem container it is a table; below that each row is two lines. IndexTableStacked and IndexTableSplit are recipes built on it.
This preview did not load.
main.astro
examples/indextable/main.astro
---
import Badge from "@astronomic-dev/ui/components/Badge.astro";
import IndexTable from "@astronomic-dev/ui/components/IndexTable.astro";
const columns = [
{ key: "family", label: "Family" },
{ key: "tier", label: "Tier" },
{ key: "parts", label: "Parts", align: "end" as const },
];
const rows = [
{ cells: { family: "Navbar", tier: "Free", parts: "6" } },
{ cells: { family: "Features", tier: "Free", parts: "6" } },
{ cells: { family: "Marquee", tier: "Free", parts: "5" } },
{ cells: { family: "Pricing", tier: "Pro", parts: "4" } },
{ cells: { family: "Bento", tier: "Pro", parts: "4" } },
];
---
<div class="mx-auto max-w-6xl px-6 py-16">
<IndexTable heading="The largest families" text="Each family is a shell and the recipes built on it, with the parts they share." columns={columns} rows={rows}>
<Badge slot="eyebrow">Astronomic UI</Badge>
</IndexTable>
</div>Minimal · Light