CodeBlock
Multi-line code display with line numbers and copy-to-clipboard functionality.
Import
Basic Usage
function greet(name: string) {
console.log(`Hello, ${name}!`);
}
greet('World');Props
| Prop | Type | Default | Description |
|---|---|---|---|
| code | string | - | The code string to display (required) |
| language | string | - | Programming language for semantic purposes |
| showLineNumbers | boolean | true | Whether to show line numbers on the left side |
| startLineNumber | number | 1 | Starting line number |
| showCopyButton | boolean | false | Whether to show the copy button |
| onCopy | (code: string) => void | - | Callback fired when code is copied |
| className | string | - | Additional CSS class names |
Variants
Basic Code Block
function greet(name: string) {
console.log(`Hello, ${name}!`);
}
greet('World');With Language Label
import { Button } from 'tuimorphic';
export function App() {
return (
<Button variant="primary">
Click me
</Button>
);
}Without Line Numbers
npm install tuimorphic
pnpm add tuimorphic
yarn add tuimorphicCustom Start Line
const handleSubmit = async (data: FormData) => {
const response = await fetch('/api/submit', {
method: 'POST',
body: data,
});
return response.json();
};