Theme
CodeBlock
Code display with optional line numbers and copy button
Start Here
Start from the smallest working snippet, then move to interactive examples and the full API contract below.
Styled quick start
Copy this entrypoint first. It includes the imports required to get the component on screen.
Import options
Root package
ts
import { CodeBlock } from '@dryui/ui'Per-component subpath
ts
import { CodeBlock } from '@dryui/ui/code-block'Customize
Use the interactive examples to see common variants, states, and composition patterns before building your own.
Syntax Highlighting
javascript
import { Button } from '@dryui/ui';
function App() {
return <Button variant="solid">Hello World</Button>;
}svelte
<CodeBlock
code={sampleCode}
language="javascript"
showCopyButton
/>With Line Numbers
typescript
1interface User {
2 id: number;
3 name: string;
4 email: string;
5}
6
7async function fetchUser(id: number): Promise<User> {
8 const res = await fetch(`/api/users/${id}`);
9 return res.json();
10}svelte
<CodeBlock
code={tsCode}
language="typescript"
showLineNumbers
showCopyButton
/>Compose
The full API contract lives here: props, CSS variables, and the public data attributes you can target when styling.
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
code | string | — | ✓ | — |
language | string | — | — | — |
showLineNumbers | boolean | false | — | — |
showCopyButton | boolean | true | — | — |
linkResolver | (text: string, type: string) => string | undefined | — | — | — |
children | Snippet | — | — | — |
Forwards <element> attributes via rest props. Common examples: id, class, aria-label.