Copyable cell

An identifier cell: the value plus a copy button that fades in on the row's hover.

Preview

Interactive examples use the same @flux/ui build as production. Toggle theme in the header for light and dark. Motion tokens and layout patterns live under Motion and Patterns in the sidebar.

Live preview

Installation

Add the package to your app (full Next.js + Tailwind steps on Installation):

npm install @payglocal_ui/flux-ui

Usage

Import

import { CopyableCell } from "@payglocal_ui/flux-ui";

Example

// Reveal-on-hover is the point. Twelve ids with twelve permanent copy buttons
// is twelve pieces of chrome competing with the data; the row the pointer is
// on is the only one whose button is useful.
<CopyableCell value={row.gid} label="Transaction ID" />

// `onClick` makes the id the handle that opens the row. The copy button stops
// propagation, so copying never also opens it.
<CopyableCell value={row.gid} label="Transaction ID" accent onClick={() => open(row)} />

// `display` shortens what is on SCREEN only — the clipboard, the tooltip and
// the accessible name all still carry the full value, so shortening what is
// shown never shortens what the user walks away with.
<CopyableCell value={row.utr} display={truncateMiddle(row.utr)} label="UTR" />

// It relies on the row's own `group` class, which every DataTable <tr> carries.
// Outside a DataTable row, put `className="group"` on an ancestor.