Empty
A space pencilled in for what has not arrived yet: an icon, a title, a line of help and what to do about it.
No sketches yet
Start a page and it will turn up here, ready to carry on with.
import { InkIcon } from "@/components/ui/ink-icons";
import { Button } from "@/components/ui/button";
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty";
export default function EmptyDemo() {
return (
<Empty seed="empty-demo" className="w-full max-w-lg">
<EmptyHeader>
<EmptyMedia variant="icon" seed="empty-demo-icon">
<InkIcon name="layers" />
</EmptyMedia>
<EmptyTitle>No sketches yet</EmptyTitle>
<EmptyDescription>Start a page and it will turn up here, ready to carry on with.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<div className="flex gap-3">
<Button seed="empty-demo-new">New sketch</Button>
<Button variant="outline" seed="empty-demo-import">
Import
</Button>
</div>
</EmptyContent>
</Empty>
);
}Installation
pnpm dlx shadcn@latest add @ballpoint/ empty"use client";
import type { ComponentProps } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
import { usePen, type Pen } from "@/hooks/use-ink-box";
import { InkOutline } from "@/lib/ink-outline";
/**
* Nothing here yet: a space pencilled in, ready to be filled. The outline is
* drawn lightly, the way a gap is marked out before it is used.
*/
function Empty({
className,
children,
seed,
roughness,
passes,
radius,
corners,
draw,
weight,
speed,
...props
}: ComponentProps<"div"> & Pick<Pen, "roughness" | "passes" | "radius" | "corners" | "draw" | "weight" | "speed"> & { seed?: string | number }) {
const pen = usePen({ roughness, passes, radius, corners, draw, weight, speed });
return (
<div
data-slot="empty"
className={cn("relative flex min-w-0 flex-1 flex-col items-center justify-center gap-6 p-8 text-center text-balance md:p-12", className)}
{...props}
>
<InkOutline pen={pen} seed={seed} estimate={[420, 280]} maxRadius={18} className="text-ink-4" />
{children}
</div>
);
}
function EmptyHeader({ className, ...props }: ComponentProps<"div">) {
return <div data-slot="empty-header" className={cn("relative flex max-w-sm flex-col items-center gap-2 text-center", className)} {...props} />;
}
const emptyMediaVariants = cva("relative mb-2 flex shrink-0 items-center justify-center [&_svg:not(.ink-sketch)]:pointer-events-none [&_svg:not(.ink-sketch)]:shrink-0", {
variants: {
variant: {
default: "bg-transparent",
icon: "size-12 text-ink-2 [&_svg:not(.ink-sketch):not([class*='size-'])]:size-6",
},
},
defaultVariants: { variant: "default" },
});
/** An icon (circled with the pen) or a picture, above the title. */
function EmptyMedia({ className, variant = "default", seed, children, ...props }: ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants> & { seed?: string | number }) {
const pen = usePen({});
return (
<div data-slot="empty-icon" data-variant={variant} className={cn(emptyMediaVariants({ variant }), className)} {...props}>
{variant === "icon" && <InkOutline pen={pen} seed={seed} shape="ring" estimate={[48, 48]} pad={5} className="text-ink-3" />}
{children}
</div>
);
}
function EmptyTitle({ className, ...props }: ComponentProps<"div">) {
return <div data-slot="empty-title" className={cn("text-xl leading-snug font-bold", className)} {...props} />;
}
function EmptyDescription({ className, ...props }: ComponentProps<"p">) {
return (
<p
data-slot="empty-description"
className={cn("text-base text-ink-3 [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-ink", className)}
{...props}
/>
);
}
function EmptyContent({ className, ...props }: ComponentProps<"div">) {
return <div data-slot="empty-content" className={cn("relative flex w-full max-w-sm min-w-0 flex-col items-center gap-3 text-base text-balance", className)} {...props} />;
}
export { Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent, EmptyMedia };Usage
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty"
<Empty>
<EmptyHeader>
<EmptyMedia variant="icon">…</EmptyMedia>
<EmptyTitle>No sketches yet</EmptyTitle>
<EmptyDescription>Start a page and it will turn up here.</EmptyDescription>
</EmptyHeader>
<EmptyContent>…</EmptyContent>
</Empty>Examples
No results
A search that found nothing, with a way to try again.
Nothing found
No notes match "margin doodles". Try a shorter word, or look in the archive.
import { InkIcon } from "@/components/ui/ink-icons";
import { Button } from "@/components/ui/button";
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty";
import { InputGroup, InputGroupAddon, InputGroupInput } from "@/components/ui/input-group";
import { Kbd } from "@/components/ui/kbd";
export default function EmptySearch() {
return (
<Empty seed="empty-search" className="w-full max-w-lg">
<EmptyHeader>
<EmptyMedia variant="icon" seed="empty-search-icon">
<InkIcon name="search" />
</EmptyMedia>
<EmptyTitle>Nothing found</EmptyTitle>
<EmptyDescription>No notes match "margin doodles". Try a shorter word, or look in the archive.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<InputGroup seed="empty-search-input">
<InputGroupInput placeholder="Search notes…" aria-label="Search notes" />
<InputGroupAddon align="inline-end">
<Kbd>/</Kbd>
</InputGroupAddon>
</InputGroup>
<Button variant="link" seed="empty-search-archive">
Look in the archive
</Button>
</EmptyContent>
</Empty>
);
}With avatars
Use avatars instead of an icon to show who is missing.
ABKLMN
Nobody else is here
Invite people to the notebook to draw alongside you.
import { Avatar, AvatarFallback, AvatarGroup } from "@/components/ui/avatar";
import { Button } from "@/components/ui/button";
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty";
import { InkGlyph } from "@/lib/ink-glyphs";
export default function EmptyAvatars() {
return (
<Empty seed="empty-avatars" className="w-full max-w-lg">
<EmptyHeader>
<EmptyMedia>
<AvatarGroup>
{["AB", "KL", "MN"].map((initials) => (
<Avatar key={initials} size="lg" seed={`empty-${initials}`}>
<AvatarFallback>{initials}</AvatarFallback>
</Avatar>
))}
</AvatarGroup>
</EmptyMedia>
<EmptyTitle>Nobody else is here</EmptyTitle>
<EmptyDescription>Invite people to the notebook to draw alongside you.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button size="sm" seed="empty-avatars-invite">
<InkGlyph name="plus" /> Invite people
</Button>
</EmptyContent>
</Empty>
);
}An error
The same layout in red pen, for something that failed.
That page didn't load
The connection dropped halfway down. Nothing was lost.
import { Button } from "@/components/ui/button";
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "@/components/ui/empty";
import { InkIcon } from "@/components/ui/ink-icons";
export default function EmptyError() {
return (
<Empty seed="empty-error" className="w-full max-w-lg">
<EmptyHeader>
<EmptyMedia variant="icon" seed="empty-error-icon" className="text-pen-red">
<InkIcon name="alert-circle" />
</EmptyMedia>
<EmptyTitle>That page didn't load</EmptyTitle>
<EmptyDescription>The connection dropped halfway down. Nothing was lost.</EmptyDescription>
</EmptyHeader>
<EmptyContent>
<Button variant="outline" seed="empty-error-retry">
<InkIcon name="refresh" /> Try again
</Button>
</EmptyContent>
</Empty>
);
}API reference
- EmptyMedia variantdefault
"default" "default" | "icon"A bare slot for anything, or an icon circled with the pen.
- seed
string | numberPins the drawing.
Pen settings
The drawing also takes draw, roughness, passes, radius, corners, weight and speed, as props or from the nearest InkProvider. What each one does.