Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Data Table with Actions for Ark UI

A payments table with ID, Status, Email and Amount. Each row ends in a menu: Copy payment ID, View customer and View payment details.

A payments table has columns ID, Status, Email and Amount. Each row ends in a menu. The menu lists Copy payment ID, View customer and View payment details.

Put row actions in a menu so they do not crowd the table. Inline buttons on a Table are fine for a single Edit. In React, Ark UI does not copy the payment id.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Usage

<div className="w-full max-w-4xl">
  <div className="rounded-md border bg-background">
    <Table>
      <TableHeader>
        {table.getHeaderGroups().map((headerGroup) => (
          <TableRow key={headerGroup.id}>
            {headerGroup.headers.map((header) => (
              <TableHead key={header.id}>
                {header.isPlaceholder ? null : (
                  <table.FlexRender header={header} />
                )}
              </TableHead>
            ))}
          </TableRow>
        ))}
      </TableHeader>
      <TableBody>
        {rows.length > 0 ? (
          rows.map((row) => (
            <TableRow key={row.id}>
              {row.getAllCells().map((cell) => (
                <TableCell key={cell.id}>
                  <table.FlexRender cell={cell} />
                </TableCell>
              ))}
            </TableRow>
          ))
        ) : (
          <TableRow>
            <TableCell
              className="h-24 text-center"
{/* The rest of the file is under Installation. */}

FAQ

Where do the row actions live?

In a display column with the id actions. Its header is a visually hidden Actions label, and its cell renders the menu for row.original.

What opens the menu?

A ghost icon Button labeled Open menu with MoreHorizontalIcon. DropdownMenuTrigger wraps it with asChild.

What does Copy payment ID do?

It writes payment.id to the clipboard with navigator.clipboard.writeText. The item runs it from onSelect. View customer and View payment details have no handler yet.

How is the menu laid out?

An Actions group label over Copy payment ID, a separator, then the two View items. The menu opens below the button, aligned to its end. That's positioning with placement: "bottom-end".

Can one item be turned off for some rows?

Yes: the menu is rendered per row from row.original, so disable an item from that row's data. Pass disabled to DropdownMenuItem.

Can I open the row menu from the keyboard?

Tab reaches the Open menu button, and Enter, Space or the down arrow opens it. The arrow keys move through the items and Escape closes the menu.

API Reference

Table

Sets colSpan={columns.length}. The rest is on the Table page.