Code Block
export const formatAmount = (cents: number, currency = 'USD') =>
new Intl.NumberFormat('en-US', { style: 'currency', currency })
.format(cents / 100)export const formatAmount = (cents: number, currency = 'USD') =>
new Intl.NumberFormat('en-US', { style: 'currency', currency })
.format(cents / 100)A block of code with a Copy button. Long lines scroll sideways in a region that takes keyboard focus, and Copy announces its result politely.
A Markdown brief for Claude, Cursor or v0: install, setup, props and a complete example.
For code or a command people copy: an install line, a config file, an API call.
A name or value inside a sentence? A plain code element in Prose.
The code sits in a region named after its label, so long lines scroll with the keyboard. Copy is a real button, and its result is announced politely; if the browser blocks the clipboard, the code is selected instead.
import { CodeBlock } from '@idyeah/diya'Stable since 1.0.0
codeRequiredstringThe code to show and copy, exactly as written. It is set in a monospace font, without syntax colors.
labelstringA short name above the code, such as its language ('TypeScript') or file ('app/page.tsx'). It also names the code for screen readers.
Also takes every native <div> attribute, such as id, aria-* or data-*.