Code Snippet
ReadyCode with a copy button.
npx @oratiq-js/ui add code-snippetapp/page.tsx
import { Button } from "@/components/ui/button";
export default function Page() {
return <Button>Get started</Button>;
}Installation
$ npx @oratiq-js/ui add code-snippetCopies the component and everything it depends on into your project, then lists the npm packages to install. The code is yours after this.
Usage
import
import { CodeSnippet } from "@/components/ui/code-snippet";Behaviour
- Pinned dir="ltr" — code is a technical sequence and never reorders with the page's direction.
- The copy button announces its state and falls back silently where the clipboard is unavailable.
- inline renders a one-line command bar; block adds a labelled header and scrolls beyond maxHeight.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
code* | string | — | The text to display and copy. |
label | string | — | Header label (block mode). |
inline | boolean | false | One-line command style. |
maxHeight | number | — | Scroll past this height. |
View source on GitHub → components/ui/code-snippet.tsx