Command Menu

Search documentation, components, and switch theme.

Atoms

Code Snippet

A read-only syntax-highlighted code viewer powered by Shiki with CSS variable theming.

Formance
Docs

Installation#

npx shadcn@latest add https://design-system-three-mauve.vercel.app/r/code-snippet.json

Install the following dependencies:

npm install shiki class-variance-authority lucide-react

Copy and paste the following code into your project.

Add the --shiki-* CSS variables to your global CSS.

The component uses CSS custom properties for syntax colors. Add these to your :root and .dark selectors:

:root {
  --shiki-foreground: var(--foreground);
  --shiki-background: transparent;
  --shiki-token-constant: var(--emerald-600);
  --shiki-token-string: var(--lilac-700);
  --shiki-token-comment: var(--emerald-500);
  --shiki-token-keyword: var(--mint-800);
  --shiki-token-parameter: var(--emerald-600);
  --shiki-token-function: var(--mint-800);
  --shiki-token-string-expression: var(--lilac-700);
  --shiki-token-punctuation: var(--foreground);
  --shiki-token-link: var(--emerald-600);
  --shiki-token-monetary: var(--gold-600);
}

.dark {
  --shiki-foreground: var(--emerald-200);
  --shiki-background: var(--emerald-800);
  --shiki-token-constant: var(--mint-700);
  --shiki-token-string: var(--lilac-500);
  --shiki-token-comment: var(--emerald-400);
  --shiki-token-keyword: var(--mint-600);
  --shiki-token-parameter: var(--mint-700);
  --shiki-token-function: var(--mint-600);
  --shiki-token-string-expression: var(--lilac-500);
  --shiki-token-punctuation: var(--emerald-300);
  --shiki-token-link: var(--mint-700);
  --shiki-token-monetary: var(--gold-300);
}

Update the import paths to match your project setup.

Usage#

import { CodeSnippet } from '@/components/code/code-snippet'
<CodeSnippet code={`const x = 42;`} language="typescript" />

Examples#

Numscript#

Dark Theme#

Light Theme#

fctl Commands#

Borderless#

Single Line#