Marker
A small note in the middle of a conversation: a status, a system message, or a label written into a pen rule.
import { InkIcon } from "@/components/ui/ink-icons";
import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker";
export default function MarkerDemo() {
return (
<div className="flex w-full max-w-md flex-col gap-4">
<Marker>
<MarkerIcon>
<InkIcon name="check-circle" />
</MarkerIcon>
<MarkerContent>Explored 4 files</MarkerContent>
</Marker>
<Marker>
<MarkerIcon>
<InkIcon name="git-branch" />
</MarkerIcon>
<MarkerContent>Switched to the redesign branch</MarkerContent>
</Marker>
<Marker variant="border">
<MarkerIcon>
<InkIcon name="search" />
</MarkerIcon>
<MarkerContent>Searched the docs for "torn paper"</MarkerContent>
</Marker>
</div>
);
}Installation
pnpm dlx shadcn@latest add @ballpoint/ marker"use client";
import { mergeProps } from "@base-ui/react/merge-props";
import { useRender } from "@base-ui/react/use-render";
import type { ComponentProps } from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
import { Separator } from "@/components/ui/separator";
const markerVariants = cva(
"relative flex min-w-0 items-center gap-2 text-sm text-ink-3 outline-none [&_svg:not(.ink-sketch):not([class*='size-'])]:size-4",
{
variants: {
variant: {
default: "",
border: "pb-2",
separator: "w-full justify-center gap-3",
},
},
defaultVariants: { variant: "default" },
},
);
/**
* A small note in the middle of a conversation: a status ("Explored 4 files"),
* a system message, or (`separator`) a label written into a pen rule, for
* dates and breaks. `render` makes it a link or a button.
*/
function Marker({ className, variant = "default", render, children, ...props }: useRender.ComponentProps<"div"> & VariantProps<typeof markerVariants>) {
return useRender({
defaultTagName: "div",
props: mergeProps<"div">(
{
className: cn(
markerVariants({ variant }),
"[a&]:hover:text-ink [button&]:hover:text-ink [a&]:focus-visible:outline-solid [button&]:focus-visible:outline-solid [a&]:focus-visible:outline-[1.5px] [button&]:focus-visible:outline-[1.5px] [a&]:focus-visible:outline-offset-2 [button&]:focus-visible:outline-offset-2 [a&]:focus-visible:outline-ring [button&]:focus-visible:outline-ring",
className,
),
children: (
<>
{variant === "separator" && <Separator aria-hidden="true" role="presentation" className="flex-1" />}
{children}
{variant === "separator" && <Separator aria-hidden="true" role="presentation" className="flex-1" delay={200} />}
{variant === "border" && <Separator aria-hidden="true" role="presentation" className="absolute inset-x-0 bottom-0" />}
</>
),
} as ComponentProps<"div">,
props,
),
render,
state: { slot: "marker", variant },
});
}
/** A decorative icon, hidden from assistive technology: say what it means in the text. */
function MarkerIcon({ className, ...props }: ComponentProps<"span">) {
return <span aria-hidden="true" data-slot="marker-icon" className={cn("inline-flex shrink-0 items-center", className)} {...props} />;
}
/** The words. Give them `motion-safe:animate-pulse` while the work is still going. */
function MarkerContent({ className, ...props }: ComponentProps<"span">) {
return <span data-slot="marker-content" className={cn("min-w-0 truncate", className)} {...props} />;
}
export { Marker, MarkerIcon, MarkerContent, markerVariants };Usage
import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker"
<Marker>
<MarkerIcon><CheckIcon /></MarkerIcon>
<MarkerContent>Explored 4 files</MarkerContent>
</Marker>Examples
Separator
A label with a pen rule either side, for dates and breaks.
The pen ran dry halfway down the page.
import { Marker, MarkerContent } from "@/components/ui/marker";
export default function MarkerSeparator() {
return (
<div className="flex w-full max-w-md flex-col gap-3">
<Marker variant="separator">
<MarkerContent>Yesterday</MarkerContent>
</Marker>
<p className="text-ink-2">The pen ran dry halfway down the page.</p>
<Marker variant="separator">
<MarkerContent>Today</MarkerContent>
</Marker>
</div>
);
}Status
role="status" and a spinner, so the update is announced; the words pulse while the work goes on.
import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker";
import { Spinner } from "@/components/ui/spinner";
export default function MarkerStatus() {
return (
<Marker role="status">
<MarkerIcon>
<Spinner />
</MarkerIcon>
<MarkerContent className="motion-safe:animate-pulse">Drawing the margin note…</MarkerContent>
</Marker>
);
}Links and buttons
Render the marker as an element that can be pressed.
import { InkIcon } from "@/components/ui/ink-icons";
import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker";
export default function MarkerLink() {
return (
<div className="flex w-full max-w-md flex-col gap-3">
<Marker render={<a href="#" />}>
<MarkerIcon>
<InkIcon name="file-text" />
</MarkerIcon>
<MarkerContent>Opened letter-to-ada.md</MarkerContent>
</Marker>
<Marker render={<button type="button" className="cursor-pointer" />}>
<MarkerIcon>
<InkIcon name="undo" />
</MarkerIcon>
<MarkerContent>Undo the last change</MarkerContent>
</Marker>
</div>
);
}API reference
- variantdefault
"default" "default" | "border" | "separator"Inline; with a rule drawn under it; or centred between two rules.
- render
ReactElementRender the marker as a link or a button.
- MarkerIcon
spanA decorative icon, hidden from assistive technology.
- markerVariants
cvaExported for building your own marker styles.
Every other prop goes to Base UI's Use Render.