Marker
Marks a point in a stream of content, such as a date, a status line or a step the agent took, without taking the weight of a message.
Installation
pnpm dlx shadcn@latest add @silkware/markerTo copy the component by hand, install its dependencies:
pnpm add class-variance-authority cnThen copy the source into components/ui/marker.tsx:
import * as React from "react"import { cva, type VariantProps } from "class-variance-authority"import { cn } from "cn"
const markerVariants = cva( "group/marker relative flex min-h-4 w-full items-center gap-2 text-left text-sm text-muted-foreground [&_svg:not([class*='size-'])]:size-4 [a]:underline [a]:underline-offset-3 [a]:hover:text-foreground", { variants: { variant: { default: "", separator: "before:mr-1 before:h-px before:min-w-0 before:flex-1 before:bg-border after:ml-1 after:h-px after:min-w-0 after:flex-1 after:bg-border", border: "border-b border-border pb-2", }, }, })
function Marker({ className, variant = "default", render, children, ...props}: React.ComponentProps<"div"> & VariantProps<typeof markerVariants> & { render?: (props: React.HTMLAttributes<HTMLElement>) => React.ReactNode }) { if (render) { const renderProps = { ...props, "data-slot": "marker", "data-variant": variant, className: cn(markerVariants({ variant, className })), children, }
return render(renderProps) }
return ( <div {...props} data-slot="marker" data-variant={variant} className={cn(markerVariants({ variant, className }))} > {children} </div> )}
function MarkerIcon({ className, ...props }: React.ComponentProps<"span">) { return ( <span data-slot="marker-icon" aria-hidden="true" className={cn( "size-4 shrink-0 [&_svg:not([class*='size-'])]:size-4", className )} {...props} /> )}
function MarkerContent({ className, ...props }: React.ComponentProps<"span">) { return ( <span data-slot="marker-content" className={cn( "min-w-0 wrap-break-word group-data-[variant=separator]/marker:flex-none group-data-[variant=separator]/marker:text-center *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground", className )} {...props} /> )}
export { Marker, MarkerIcon, MarkerContent, markerVariants }Usage
import { Marker, MarkerContent, MarkerIcon } from "@/components/ui/marker"<Marker> <MarkerIcon> <SearchIcon /> </MarkerIcon> <MarkerContent>Searched 3 supplier files</MarkerContent></Marker>A marker is one line of muted text, with an optional icon. It sits between messages in a conversation, for example "Today" or "Reading 4 supplier files". It is presentational until you give it a role: add role="status" when it reports work in progress. The conversation patterns that use markers are Chat and Checkpoint.
Examples
Variants
default is an inline line of text. separator centres the text between two thin rules and suits dates and section breaks. border adds a rule under the line to separate it from the next row.
Status
For work in progress, set role="status" and add a Spinner. The marker is a polite live region, so assistive technology announces the text when it appears.
Shimmer
Add the shimmer class to MarkerContent for a moving highlight across the text. It is a cue, not a label, so keep role="status" and write the text for someone who sees no animation. The effect stops for readers who ask for reduced motion.
Separator
A separator with text needs no role. The rules are drawn with CSS, and the text is read as ordinary content. Use it for dates, for the time an agent worked and for people joining or leaving.
Border
A bordered marker keeps the default alignment and draws a line under itself. Use it for a short list of steps that you want to keep apart.
With icon
MarkerIcon holds a 16px icon and is hidden from assistive technology. Add flex-col to stack the icon above the text.
Link or button
render turns the marker into a real a or button. It gets the underline of a link or, for a button, the hover colour you give it. The accessible name is the text of the marker.
Accessibility
A plain marker is text and has no keyboard behaviour. The keys below apply to a marker rendered as a link or a button.
| Key | Action |
|---|---|
| Tab | Moves focus to a marker rendered as a link or a button. |
| Enter | Follows the link or presses the button. |
| Space | Presses a marker rendered as a button. |
The component provides:
aria-hiddenonMarkerIcon, so the text alone names the marker.- Any ARIA attribute you pass to
Marker, includingroleandaria-label, forwarded to the element it renders. - The element you choose with
render, which brings its own role and keyboard behaviour.
You provide:
role="status"on a marker that reports work in progress, with the text that says what is happening.- No role on a separator that has text. Do not add
role="separator": it takes its name fromaria-label, treats its children as presentational and hides the visible text from screen readers. - An
aria-labelon a marker that has an icon and no text, so it is not announced as empty. Give itrole="img"as well so the label is exposed. - A real
aorbutton, throughrender, for a marker that does something. Do not add a click handler to the defaultdiv.
Guidelines
When to use
- For a date or a section break in a conversation or a log.
- For a status line while an agent works: "Reading 4 supplier files".
- For a note about what happened between two messages: "Luca joined the conversation".
- For a short step in a list of steps, as a bordered row.
When not to use
- For something a person said. Use a Message with a Bubble.
- For a message about the page that must be seen. Use an Alert.
- For a divider with no text between sections of a layout. Use a Separator.
- For a step the person can open to read detail. Use a Trace.
- For a status label on a record. Use a Badge.
Content
- Say what happened or what is happening, with the object: "Reading 4 supplier files", "Worked for 42 seconds".
- Use the present tense while it runs and the past tense when it is done, and change the same marker rather than adding a new one.
- Use sentence case. Do not add an ellipsis, a full stop or an exclamation mark.
- Do not use a marker for anything the person must act on. Put that in a message or an alert.
Concrete text
A marker is small, so its text has to carry the information. A line that says only that something is going on tells the reader nothing and never changes.
Say what is being done and to what.
Don’t write "Working...". It is announced and read, and it says nothing.
Give a marker that is only an icon an accessible name.
Don’t leave an icon-only marker empty for assistive technology. The icon is hidden and nothing remains to read.
API reference
Marker
Renders a <div>, a flex row with the muted colour. With render it renders your element, such as an a or a button, and passes it the props to spread.
| Prop | Type | Default | Description |
|---|---|---|---|
variant? | "default" | "separator" | "border" | "default" | The layout: an inline line, a centred label between two rules, or a line with a border under it. |
render? | (props: HTMLAttributes<HTMLElement>) => ReactNode | None | A function that returns the element to render, such as an anchor or a button. |
role? | string | None | The ARIA role. Use status for a marker that reports work in progress. |
className? | string | None | Classes merged after the variant classes. |
MarkerIcon
Renders a <span> of 16px, hidden from assistive technology, for an icon or a spinner.
| Prop | Type | Default | Description |
|---|---|---|---|
children? | ReactNode | None | An icon or a Spinner. |
className? | string | None | Classes merged after the icon classes. |
MarkerContent
Renders a <span> with the text. It wraps long words. In the separator variant it does not stretch, so the rules take the free width.
| Prop | Type | Default | Description |
|---|---|---|---|
className? | string | None | Classes merged after the content classes. Add shimmer for a moving highlight. |
markerVariants
The class function behind Marker, from class-variance-authority. Call it to give another element the marker styles.