Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat(table): add opt-in sticky header (#8288)
Andrew Huangfd316ab9103e
diff --git a/frontend/src/components/v3/generic/Table/Table.stories.tsx b/frontend/src/components/v3/generic/Table/Table.stories.tsxindex c726bfd7bb..ec2e464cc5 100644--- a/frontend/src/components/v3/generic/Table/Table.stories.tsx+++ b/frontend/src/components/v3/generic/Table/Table.stories.tsx@@ -87,6 +87,8 @@ const identities: Identity[] = [* structure, a `<ul>` of `Item`s is usually a better fit.** Useful per-cell flags:+ * - **`sticky`** on `TableHeader` pins the header while scrolling a table+ * with a height-constrained container (`containerClassName="max-h-40"`).* - **`isTruncatable`** on `TableHead` / `TableCell` clips long content with* ellipsis instead of letting the column blow out the row width.* - **`data-state="selected"`** on a `TableRow` paints the selected highlight@@ -156,6 +158,40 @@ export const Default: Story = {)};+export const StickyHeader: Story = {+ name: "Example: Sticky Header",+ parameters: {+ docs: {+ description: {+ story:+ "Set `sticky` on `TableHeader` and constrain the table container height with `containerClassName`. The header stays visible while the rows scroll; by default, headers are not sticky."+ }+ }+ },+ render: () => (+ <Table containerClassName="max-h-40">+ <TableHeader sticky>+ <TableRow>+ <TableHead>Name</TableHead>+ <TableHead>Role</TableHead>+ <TableHead>Status</TableHead>+ </TableRow>+ </TableHeader>+ <TableBody>+ {identities.map((id) => (+ <TableRow key={id.name}>+ <TableCell className="font-medium">{id.name}</TableCell>+ <TableCell>{id.role}</TableCell>+ <TableCell>+ <Badge variant="success">Active</Badge>+ </TableCell>+ </TableRow>+ ))}+ </TableBody>+ </Table>+ )+};+export const WithCaption: Story = {name: "Anatomy: With Caption",parameters: {diff --git a/frontend/src/components/v3/generic/Table/Table.tsx b/frontend/src/components/v3/generic/Table/Table.tsxindex 34d31db297..fa779adbbd 100644--- a/frontend/src/components/v3/generic/Table/Table.tsx+++ b/frontend/src/components/v3/generic/Table/Table.tsx@@ -26,11 +26,19 @@ const Table = React.forwardRef<Table.displayName = "Table";-function TableHeader({ className, ...props }: React.ComponentProps<"thead">) {+function TableHeader({+ className,+ sticky = false,+ ...props+}: React.ComponentProps<"thead"> & { sticky?: boolean }) {return (<theaddata-slot="table-header"- className={cn("text-sm [&_tr]:border-b [&_tr]:hover:bg-transparent", className)}+ className={cn(+ "text-sm [&_tr]:border-b [&_tr]:hover:bg-transparent",+ sticky && "sticky top-0 z-10 bg-container",+ className+ )}{...props}/>);