Code Block
aqua/code-blockFreeComponent
Shiki-highlighted code card with an Aqua copy button.
Live preview
live · rendered by the registry
Rendered by aqua on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://aqua.duca.dev/r/code-block.jsonSource
1import { codeToHtml } from "shiki"23import { cn } from "@/lib/utils"4import { CopyButton } from "@/registry/aqua/ui/copy-button"56export async function CodeBlock({7 code,8 lang = "tsx",9 theme = "github-light",10 className,11}: {12 code: string13 lang?: string14 theme?: string15 className?: string16}) {17 const html = await codeToHtml(code, { lang, theme })1819 return (20 <div className={cn("relative", className)}>21 <div22 className="overflow-x-auto rounded-xl border border-[#aeb3bc] bg-white shadow-[0_2px_10px_rgba(20,30,50,0.08)] [&_pre]:!bg-transparent [&_pre]:p-5 [&_pre]:font-mono [&_pre]:text-[13px] [&_pre]:leading-6"23 dangerouslySetInnerHTML={{ __html: html }}24 />25 <CopyButton text={code} className="absolute right-3 top-3" />26 </div>27 )28}
What it pulls in
npm packages
Files it writes
More from aqua
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Alertalert | aqua | Components | Free | 1 dep | |
| Avataravatar | aqua | Components | Free | 1 dep | |
| Badgebadge | aqua | Components | Free | 2 deps | |
| Buttonbutton | aqua | Components | Free | 2 deps | |
| Chat Bubblechat-bubble | aqua | Components | Free | no deps | |
| Checkboxcheckbox | aqua | Components | Free | 2 deps | |
| Cursorcursor | aqua | Components | Free | no deps | |
| Dialogdialog | aqua | Components | Free | 1 dep |
