Inline code in a sentence (a path, a key, a version or a command) in mono on a muted tile at the text's size, breaking anywhere on a phone, with no copy button of its own.
In text
Install
npx shadcn add @syncrobotic/code Also installs: @syncrobotic/cn
Overview
When to use
- "Set max_items in the config": a key or a file in help text and descriptions.
- A reference such as group/name@v3 in a table cell or a caption.
- A short command inside a sentence.
Use something else
- Code or a command on its own lines, with copy: Code block.
- A key to press: Kbd.
- A value to copy: Copy button beside the Code.
More examples
States and real uses. Each example is also a Storybook story and a visual regression test.
Sizes
Long path
With copy
Usage rules
- A path, a key, a version tag or a command inside a sentence or a cell. Code on its own lines is a CodeBlock; a key to press is a Kbd.
- It takes the size of the text around it; never give it a size of its own.
- No copy button inside. For a reference people paste, put a CopyButton beside it.
- Words, not values to edit: a value someone changes is an Input.
Changelog
- 0.64.02026-12-01Formatted with Prettier (class order sorted); the code is unchanged.
- 0.58.02026-11-28Stable: shipped ten releases with no breaking change, with unit tests, measured accessibility (components) and use/instead docs. Its API now changes only after a release deprecates what goes, with a migration line.
- 0.53.02026-11-27Its doc opens with its description, word for word; the code is unchanged.