DocsExamples

Examples

Dynamic Columns Example

An example of Shadcn Table which shows how to fetch remote data and generate columns dynamically

This example shows how to generate column definitions dynamically from remote data after first render using TanStack Query. You may need to manage the columnOrder state manually if doing this.

Try it

  1. Click Show/Hide columns. The six columns listed were built from the fetched data.
  2. Click Last Name and choose Sort ascending. The server sorts the rows.
  3. Click page 2. The server sends rows 11 to 20.
Storybook