Object Header
ObjectHeader is the small row at the top of a record page. It names the object type and gives one-click copies of the page URL and the object ID, with the avatars of anyone else looking at the same record.
@dentil/object-headerOn this page
£1,250.00
Billed to Ada Lovelace · Due 1 Dec 2026
'use client';
import { Receipt } from 'lucide-react';
import { useState } from 'react';
import { ObjectHeader } from '@/components/dentil/object-header/object-header';
export function ObjectHeaderOverviewDemo() {
const [copied, setCopied] = useState<string | null>(null);
return (
<div className="bg-background w-full max-w-2xl overflow-hidden rounded-lg border">
<ObjectHeader
icon={Receipt}
title="Invoice"
id="in_1QX4b2Lk9mT8pR7s"
url
presence={[
{ id: 'me', name: 'Ada Lovelace' },
{ id: 'u_2', name: 'Grace Hopper' },
{ id: 'u_3', name: 'Alan Turing' },
]}
onCopy={(value) => setCopied(value)}
/>
<div className="px-5 pt-1 pb-5">
<h3 className="text-lg leading-9 font-bold">£1,250.00</h3>
<p className="text-muted-foreground truncate text-sm" aria-live="polite">
{copied ? `Copied ${copied}` : 'Billed to Ada Lovelace · Due 1 Dec 2026'}
</p>
</div>
</div>
);
}Installation
pnpm dlx shadcn@latest add @dentil/object-headernpx shadcn@latest add @dentil/object-headeryarn dlx shadcn@latest add @dentil/object-headerbunx --bun shadcn@latest add @dentil/object-headerFiles land in components/dentil/object-header/. It uses no shadcn components, only lucide-react icons. The avatars animate in with tw-animate-css, which shadcn sets up by default.
Usage
Put it above the page heading. Its 20px side padding and 12px top padding line up with @dentil/dashboard-layout. There's no toast built in, so pass onCopy to show one with your own toaster.
import { Receipt } from 'lucide-react';
import { toast } from 'sonner';
import { ObjectHeader } from '@/components/dentil/object-header/object-header';
<ObjectHeader
icon={Receipt}
title="Invoice"
id={invoice.id}
url
onCopy={() => toast.success('Copied to clipboard')}
/>
<DashboardHeader>
<DashboardHeading>{invoice.total}</DashboardHeading>
</DashboardHeader>Share links
Pass a string to url to copy something other than the page address.
// Copy a link that works for teammates in other accounts, instead of the page's own address.
<ObjectHeader
icon={Receipt}
title="Invoice"
id={invoice.id}
url={`${origin}/b/${account.id}?destination=${encodeURIComponent(pathname)}`}
/>Presence
presence takes a plain array, so it works with any realtime provider. Put the current user first: earlier avatars sit on top of later ones. Names show on hover.
'use client';
import { UserRound } from 'lucide-react';
import { useState } from 'react';
import { ObjectHeader, type ObjectHeaderUser } from '@/components/dentil/object-header/object-header';
import { Button } from '@/components/ui/button';
const people: ObjectHeaderUser[] = [
{ id: 'u_2', name: 'Grace Hopper' },
{ id: 'u_3', name: 'Alan Turing' },
{ id: 'u_4', name: 'Katherine Johnson' },
{ id: 'u_5', name: 'Margaret Hamilton' },
{ id: 'u_6', name: 'Edsger Dijkstra' },
{ id: 'u_7', name: 'Barbara Liskov' },
];
const me: ObjectHeaderUser = { id: 'me', name: 'Ada Lovelace' };
export function ObjectHeaderPresenceDemo() {
const [count, setCount] = useState(2);
return (
<div className="flex w-full max-w-2xl flex-col gap-4">
<div className="bg-background overflow-hidden rounded-lg border pb-3">
<ObjectHeader
icon={UserRound}
title="Customer"
id="cus_R8fK2mQ7xLp4Vn"
presence={[me, ...people.slice(0, count)]}
/>
</div>
<div className="flex gap-2">
<Button size="sm" variant="secondary" disabled={count === people.length} onClick={() => setCount(count + 1)}>
Someone joins
</Button>
<Button size="sm" variant="secondary" disabled={count === 0} onClick={() => setCount(count - 1)}>
Someone leaves
</Button>
</div>
</div>
);
}Liveblocks
Map the current user and the others in the room to users.
import { useOthersMapped, useSelf } from '@liveblocks/react';
function InvoiceHeader({ invoice }: { invoice: Invoice }) {
const self = useSelf((me) => me.info);
const others = useOthersMapped((other) => other.info);
return (
<ObjectHeader
icon={Receipt}
title="Invoice"
id={invoice.id}
url
presence={[
...(self ? [{ id: 'self', name: self.name, avatar: self.avatar }] : []),
...others.map(([connectionId, info]) => ({ id: String(connectionId), name: info.name, avatar: info.avatar })),
]}
/>
);
}API reference
ObjectHeader
| Prop | Type | Default | Description |
|---|---|---|---|
| title | ReactNode | — | The object type, such as "Invoice" or "Customer". Truncates. |
| icon | LucideIcon | — | Icon shown before the title at 12px. |
| id | string | — | The object ID. Shown as a copy button labelled with the ID, truncated past 240px. |
| url | string | true | — | Shows a copy button labelled "URL". Pass the URL to copy, or true to copy window.location.href at the moment of the click, which is safe to render on the server. |
| presence | ObjectHeaderUser[] | — | People viewing the record, as { id?, name, avatar? }. Rendered with ObjectHeaderPresence. Hidden when empty. |
| onCopy | (value: string) => void | — | Called after a value is written to the clipboard, e.g. to show a toast. |
| children | ReactNode | — | Extra actions, placed between the avatars and the copy buttons. |
| className | string | — | Merged onto the row. |
| …props | Omit<ComponentProps<'div'>, 'title' | 'id' | 'onCopy'> | — | Other div props. |
ObjectHeaderCopyButton
| Prop | Type | Default | Description |
|---|---|---|---|
| value | string | (() => string) | — | Text written to the clipboard, or a function that returns it when clicked. |
| onCopy | (value: string) => void | — | Called after the value is copied. |
| children | ReactNode | — | The label, in a monospace font. Truncates. |
| aria-label | string | 'Copy' | Accessible name. Reads "Copied" for two seconds after a copy. |
ObjectHeaderPresence
| Prop | Type | Default | Description |
|---|---|---|---|
| users | ObjectHeaderUser[] | — | People viewing the record. Each needs a name; avatar is an image URL, and without one the avatar shows the first letter of the name. id is the React key and falls back to the name. |
| max | number | 5 | Avatars shown before the rest collapse into a "+N" count. Hover the count to see their names. |