Skip to content

Blocks reference

Blocks are the reusable pieces every Pulze page is built from. They all live in src/blocks/ and are imported from one place:

import { KpiCard, Card, CardHeader, StatusPill, EmptyState, toast } from "@pulze/blocks"

Open Pages › Blocks in the app (/blocks) to see every block live. The switch at the top shows each one loading, empty and failing.

Charts, tables and forms have their own guides: Charts, Tables, Forms.


Card and CardHeader

The surface everything sits on. Padding follows the density setting.

<Card>
  <CardHeader
    title="Top products"
    description="By units sold"
    action={<Link href="/apps/products">View all</Link>}
  />
  …
</Card>
Prop (CardHeader) Type Notes
title ReactNode Required
description ReactNode One line under the title
action ReactNode Right side: legend, Segmented, link, menu
as "h2" | "h3" Heading level, default "h2" (under the page's h1). Use "h3" for cards inside a section that has its own h2.

Card takes any <section> prop (className, id, aria-*).

KpiCard

A headline number that counts up, with an icon, a trend line and the change.

<KpiCard
  label="Revenue"
  icon={Wallet}
  value={summary.revenue}
  format={(n) => formatMoney(n, { whole: true })}
  delta={delta(summary.revenue, summary.revenuePrev)}
  note="vs last month"
  trend={summary.daily}
/>
Prop Type Default Notes
label string Required
value number Money in minor units
format (n) => string rounds How the number is shown while counting
delta number Ratio vs before (0.124 = +12.4%). Omit to hide
deltaLabel string Text instead of a percentage ("+$4.10")
invertDelta boolean false Down is good (refunds, response time)
note ReactNode After the delta ("vs last 30 days")
icon Lucide icon
color CSS colour var(--primary) Icon chip and sparkline
trend number[] Draws a sparkline
action ReactNode Top-right (menu button)
loading boolean false Shows KpiSkeleton

Delta

<Delta value={0.124} />                 // ↑ 12.4% (green)
<Delta value={-0.12} invert />          // ↓ 12% (green: down is good)
<Delta value={0.05} label="+$4.10" />

StatusPill and Tag

<StatusPill tone="success">Paid</StatusPill>
<Tag color="var(--chart-4)">Design</Tag>

Tones: success, info, warning, danger, neutral, primary. Set dot={false} to hide the dot.

Map your statuses once and reuse the map:

const INVOICE_TONE = { paid: "success", pending: "warning", overdue: "danger", draft: "neutral" } as const
<StatusPill tone={INVOICE_TONE[invoice.status]}>{label}</StatusPill>

Avatar and AvatarStack

<Avatar name="Maya Patel" hue={262} size={32} />
<Avatar name="Maya Patel" avatarUrl="/people/maya.jpg" />
<AvatarStack people={team} max={4} size={26} />

Without a photo, the avatar shows initials on a gradient made from hue (0–359). Sample users already have a hue. For your own users, pick one from their id: hue = hash(id) % 360.

FileIcon

<FileIcon name="Q4-board-deck.pdf" />   // PDF tile
<FileIcon name="xlsx" size={34} />

Colours per type are in file-icon.tsx (COLORS). Add your own extensions there.

ProgressBar and SplitBar

<ProgressBar value={0.72} />                       // 0–1
<ProgressBar value={0.45} color="var(--chart-2)" size="sm" />
<SplitBar parts={[{ label: "Desktop", value: 62, color: "var(--chart-1)" }, …]} />

Bars fill once when they appear (not when motion is off).

StatTrio

<StatTrio
  items={[
    { label: "Target", value: "$100k" },
    { label: "Revenue", value: "$84.3k" },
  ]}
/>

Timeline and ActivityFeed

<Timeline items={[{ id: "1", title: "Sent to Northwind", time: "Nov 24, 16:40", color: "var(--primary)" }]} />

<ActivityFeed
  items={[{ id: "a", actor: { name: "Rohan Mehta", hue: 24 }, text: <>moved <b>Northwind renewal</b></>, time: "12 min ago" }]}
/>

ActivityFeed items can have a quote (shown as a chat bubble).


Loading, empty and error

Every block that loads data has three extra looks. Use them on every page, and nobody ever sees a blank card.

Skeletons

<Skeleton className="h-4 w-1/2" />     // any shape
<SkeletonText lines={3} />
<KpiSkeleton />                         // or KpiCard loading
<ChartSkeleton height={300} />
<ListSkeleton rows={5} avatar />

Skeletons shimmer softly. The shimmer stops with reduced motion or with Animations off.

EmptyState

<EmptyState
  illustration="orders" // orders · search · inbox · files · chart · error · people · calendar
  title="No orders yet"
  description="When customers buy something, their orders show up here."
  action={<Button>Create test order</Button>}
  secondaryAction={<Button variant="outline">Read the guide</Button>}
  compact // smaller, for inside cards
/>

Always give a next step. An empty state with no button is a dead end. illustration can also be your own React element.

ErrorState

<ErrorState onRetry={() => query.refetch()} />
<ErrorState title="Couldn't load invoices" description="…" />

QueryState: all three in one line

<QueryState
  query={orders} // a TanStack Query result
  skeleton={<ListSkeleton />}
  isEmpty={(d) => d.items.length === 0}
  empty={<EmptyState title="No orders yet" />}
>
  {(data) => <OrdersList rows={data.items} />}
</QueryState>

Toasts

<Toaster /> is already mounted at the app root. Call toast anywhere:

toast.success("Invoice sent", {
  description: "INV-1048 was emailed to ap@northwind.com.",
})
toast.error("Payment failed")
toast.warning("Storage almost full")
toast.info("New version available", { action: { label: "Update", onClick: update } })
toast.undo("3 users deleted", () => restore(ids)) // Undo button, 5 seconds
toast.promise(save(), { loading: "Saving…", success: "Saved", error: "Couldn't save" })

Toasts appear top-right, show at most 3 at once, and leave after 5 seconds. Hovering pauses them. Change these defaults in feedback/toast.tsx.

Undo instead of "Are you sure?" For actions you can reverse (delete a row, archive a mail), act immediately and offer toast.undo. Save ConfirmDialog for things you can't take back.

ConfirmDialog

const [open, setOpen] = useState(false)

<ConfirmDialog
  open={open}
  onOpenChange={setOpen}
  title="Delete 3 users?"
  description="They lose access right away. Their files and comments stay."
  confirmLabel="Delete users"
  requireText="DELETE"            // optional: must be typed first
  onConfirm={async () => { await deleteUsers(ids) }}   // spinner while it runs
/>
Prop Default Notes
tone "danger" "primary" for non-destructive confirmations
icon trash Any Lucide icon
cancelLabel "Cancel"

SideDrawer

<SideDrawer
  open={open}
  onOpenChange={setOpen}
  title="New onboarding flow"
  description="Mobile app v2 · In progress"
  width={520}
  footer={
    <>
      <Button variant="outline">Close</Button>
      <Button>Save</Button>
    </>
  }
>
  …details…
</SideDrawer>

Header and footer stay put; the middle scrolls. side="left" is available.