Markdown
Rendered agent markdown (GFM) whose code fences compose Code, and diff fences compose CodeDiff.
Composition
The preferred shape for composing the installed primitive from its exported parts.
Parts
Exported compound parts from the installed source.
MarkdownRoot └── Markdown
First install and activate one skin. Core deliberately contains no visual token defaults.
The Control UI source installs this primitive from src/registry/sources/control-ui/ui/markdown.tsx. Install it on its own with the command above, or inspect the source below.
npx shadcn@latest add https://control-ui.dev/r/markdown.jsonKnobs
Typed custom properties the recipe paints with. Set one on the root — style, a utility class, or a skin — and every slot inherits it.
--cui-markdown-* · 9 knobsHow the cascade resolves--cui-markdown-foreground<color>oklch(from var(--foreground) l c h / 0.9)--cui-markdown-blockquote-border-color<color>var(--border)--cui-markdown-blockquote-foreground<color>var(--muted-foreground)--cui-markdown-inline-code-background<color>color-mix(in oklab, var(--foreground) 8%, transparent)--cui-markdown-inline-code-foreground<color>var(--foreground)--cui-markdown-inline-code-radius<length-percentage>+0.25rem--cui-markdown-link-foreground<color>var(--primary-text)--cui-markdown-table-cell-border-color<color>var(--border)--cui-markdown-table-header-background<color>var(--muted)Installed dependencies
Support files installed with this primitive — shared ones arrive once with your first Control UI component. Public dependencies stay linked to their own pages.
src/registry/sources/control-ui/ui/markdown-elements.tsxSupportsrc/registry/lib/diff.tsSupportsrc/registry/lib/code-tokens.tsSupportsrc/registry/sources/control-ui/code.cssSupportLibrary dependencies
Public registry items keep their source on their own documentation page instead of duplicating it here.
Raw code
This primitive's source and the support files it installs with
"use client";import type { ComponentProps, CSSProperties } from "react";import { Streamdown } from "streamdown";import type { MarkdownKnobStyle } from "@/components/control-ui/knob-contracts/markdown-knobs";import { cn } from "@/components/control-ui/lib/cn";import { markdownComponents } from "@/components/control-ui/ui/markdown-elements";export type MarkdownProps = Omit<ComponentProps<"div">, "children" | "style"> & { content: string; style?: CSSProperties & MarkdownKnobStyle;};// Chrome-less on purpose so it drops straight into chat message; MarkdownBlock composes it for headered, copyable block.// Markdown parts read their paint from knobs this root declares, so prose assembled elsewhere (MDX) needs it too.export function MarkdownRoot({ className, ...props}: Omit<ComponentProps<"div">, "style"> & { style?: CSSProperties & MarkdownKnobStyle }) { return ( <div data-control-ui="markdown" data-control-family="markdown" data-slot="root" className={cn("[&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className)} {...props} /> );}export function Markdown({ content, className, ...props }: MarkdownProps) { return ( <MarkdownRoot className={className} {...props}> <Streamdown mode="streaming" parseIncompleteMarkdown controls={false} components={markdownComponents} className="space-y-4 whitespace-normal [&>*:first-child]:mt-0 [&>*:last-child]:mb-0" > {content} </Streamdown> </MarkdownRoot> );}export type MarkdownComponentProps = ComponentProps<typeof Markdown>;