CodeBlock
Monospace code panel with title and copy button.
Code
import * as React from 'react';
import { CodeBlock } from '@fruit-labs/design';
export default function Demo() {
return (
<CodeBlock
title="Install"
code={'npm install react react-dom\n# then import tokens.css and fruit.css'}
/>
);
}Install
From npm:
npm install @fruit-labs/design
import { CodeBlock } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/code-block.jsonGuidelines
- Use for snippets, commands and JSON. No syntax colors by default; bring your own highlighter if needed.
Props
| Prop | Type | Required |
|---|---|---|
code | string | Yes |
language | string | No |
title | string | No |
className | string | No |