Code block
Source or output, tokenized by @tanstack/highlight
src/charge.ts
ts
import { Effect } from "effect";type Charge = {cents: number;paid: boolean;};// Retry twice, then settle.export const charge = (n: number) =>Effect.map(settle(n), (cents) => ({cents: Math.round(n * 100),paid: true,}));
Usage
import { CodeBlock } from "@gpuixui/components/code-block";
<CodeBlock
code={source}
title="src/app.tsx"
language="tsx"
lineNumbers
/>;API
| Prop | Type | Default |
|---|---|---|
code | string | — |
title | string | falls back to path |
path | string | — |
language | string | path's extension |
lineNumbers | boolean | false |
height | number | — |
level | SurfaceLevel | "normal" |
emptyLabel | string | "No code" |
copyLabel | string | "Copy" |
copiedLabel | string | "Copied" |
onCopy | (code: string) => void | — |
className | string | — |
style | StateStyle<CodeBlockState> | — |
Edit this page on GitHubpackages/components/docs/code-block.mdx