Menu

Code block

Code snippet with copy. 2 themes.

add-tea.sh
npx uix-ui@latest initnpx uix-ui@latest add button card

Installation

$ npx uix-ui@latest add code-block

This copies the file into components/ui/code-block.tsx in your project. npx shadcn@latest add @uix/code-block works too.

Usage

code-block.tsx
import { CodeBlock } from "@/components/ui/code-block";

<div style={{ width: 460, maxWidth: "100%" }}>
  <CodeBlock filename="add-tea.sh" code={"npx uix-ui@latest init\nnpx uix-ui@latest add button card"} />
</div>

Props

PropTypeDefaultDescription
themedark | light"dark"
codestring–Source text; each line gets a number and keywords / strings are colored.
filenameReact.ReactNode–
showHeaderbooleantrueBar with the file name and a copy button.
showLineNumbersbooleantrue

Everything else is passed to the root element, so className, aria-* and event handlers work as usual.

Dependencies

Installed for you by the CLI.

  • class-variance-authority
  • clsx
  • tailwind-merge
  • lib/utils.ts
  • components/ui/icons.tsx
esc

↑↓ to navigate · ↵ to select · esc to close