Code / CodeBlock
Code formats short inline tokens, while CodeBlock presents multiline or copyable snippets.
Purpose
Code formats short inline tokens. CodeBlock presents multiline or copyable snippets.
Inline and block code
Installation
With the Siteplane registry alias configured, add the component and import the installed source from your app.
CLI
pnpm dlx shadcn@4.16.1 add @siteplane/codeImport
import { Code, CodeBlock } from "@/components/ui/code";Need the machine-readable source metadata? View registry JSON.
Usage
Use Code / CodeBlock for inline tokens and CodeBlock for copyable multi-line examples.
import { Code, CodeBlock } from "@/components/ui/code";
export function Example() {
return (
<>
<Code>pnpm dev</Code>
<CodeBlock copyable value="pnpm dlx shadcn@4.16.1 add @siteplane/button" />
</>
);
}Examples
Inline tokens, plain blocks, copy and mask actions and both sizes are props of the same two primitives.
Inline code
Block code
Copyable
Masked
mask hides the value until revealed. Combine it with copyable for secrets that should stay readable to machines only.
Sizes
API Reference
The reference lists the source-owned exports and props that are easy to miss in visual examples. Inherited Base UI props remain available unless the wrapper narrows them.
- Use
Codeinside prose andCodeBlockfor complete snippets. - Use
maskonly with the built-in reveal and copy actions. - Keep copy and reveal actions in the reserved top-right action area.
- Leave enough right-side padding for actions in long snippets.
Motion
Component motion uses the shared Siteplane motion contract. See the global motion guide for provider setup, tokens and reduced-motion behavior.
- Code itself does not animate.
- Copy and reveal feedback uses the native action behavior and global reduced-motion contract.
Accessibility
- Masked content requires a clearly named reveal control and a clearly named copy control.
- Do not rely on syntax color alone to explain a snippet.
- Never place real secrets in documentation, screenshots, or examples.
Implementation Guidance
- Use Code for short inline tokens and CodeBlock for multiline snippets.
- Do not build custom copy overlays around CodeBlock.
- Keep all examples safe to publish.