Search docs

Jump to any table example

Storybook

Install tables with the shad-table CLI and each one can come with a Storybook story and a docs page, rendered with its demo data. The CLI asks first: it never sets up Storybook or writes a story without your OK.

Install a table

terminal
npx shad-table add data-table

Needs a shadcn project (a components.json). Every docs page has this command: pick CLI in its install box.

When it asks

Your project has StorybookAsks “Add a Storybook story for data-table?”. Enter means yes.
Your project has no StorybookAsks whether to set Storybook up. Enter means no, and nothing in your project changes.
No terminal to ask in (CI, an agent, a pipe) or -yLeaves Storybook alone and prints the command to run. Pass --stories to add stories anyway.

What you get

The story sits next to the table and renders the demo the table ships with. It is plain CSF with no Storybook imports, so it works with any React Storybook (Vite, Next.js, TanStack Start) and still typechecks in a project without Storybook. The autodocs tag gives it a docs page with the table's description, install command and a link back here.

files
components/tables/data-table/
├── columns.tsx
├── data-table-filter.tsx
├── data-table.tsx
├── index.tsx the demo, with sample rows
└── data-table.stories.tsx the story: renders the demo, autodocs on
data-table.stories.tsx
// Generated by shad-table (https://www.shad-table.dev). Edit freely: it's your file now.
// Renders the demo that ships with this table, with its sample data.
import { BasicTableUsage } from './index'
export default {
title: 'Tables/Data Table',
component: BasicTableUsage,
tags: ['autodocs'],
parameters: {
layout: 'padded',
docs: {
description: {
component: "Sortable, filterable, paginated client-side table with a composable filter toolbar.\n\n```bash\nnpx shad-table add data-table\n```\n\n[Documentation](https://www.shad-table.dev/data-table) · Generated by [shad-table](https://www.shad-table.dev).",
},
},
},
}
export const Default = {}

After you adapt the table

Once the table shows your data, the demo in index.tsx usually goes away. Point the story at the table itself, with fixture rows of your own type, and add the states you care about. The story is your file now: edit it like any other.

data-table.stories.tsx
import type { Meta, StoryObj } from '@storybook/react-vite'
import { columns } from './columns'
import { DataTable } from './data-table'
import { invoices } from '@/test/fixtures'
const meta = {
title: 'Billing/Invoices table',
component: DataTable,
tags: ['autodocs'],
args: { columns, data: invoices },
} satisfies Meta<typeof DataTable>
export default meta
export const Default: StoryObj<typeof meta> = {}
export const Empty: StoryObj<typeof meta> = { args: { data: [] } }

Commands

npx shad-table add <table…>Installs the tables with the shadcn CLI (the v8 or v9 build, from your package.json), then asks about Storybook.
npx shad-table storybook initSets Storybook up, imports your global CSS in .storybook/preview so tables render styled, and adds a story for every table you already installed.
npx shad-table stories [table…]Adds stories for installed tables that don’t have one yet. Never overwrites a story you edited unless you pass -o.
OptionEffect
--storiesAdd the story without asking
--no-storiesDon’t ask about Storybook
--v8 / --v9Pick the TanStack Table build (default: what package.json has)
-ySkip prompts; Storybook is left alone unless --stories
-oOverwrite existing files
-c <dir>Run in another project folder

Without the CLI

Each story is a shadcn registry item too, one per table for both the v8 and v9 builds. Install the table first: the story imports its demo.

terminal
npx shadcn add https://www.shad-table.dev/r/stories/data-table-story.json

3 tables have no story because their demo loads rows through a server function in the docs app: server-pagination-table, server-filter-table, server-combined-table. The CLI installs them as usual and says so. Source: packages/cli.