# Code

Syntax-highlighted code block (50+ languages)



<ComponentPreview base="ink" name="code-demo" />

Installation [#installation]

<CodeTabs>
  <TabsList>
    <TabsTrigger value="cli">
      Command
    </TabsTrigger>

    <TabsTrigger value="manual">
      Manual
    </TabsTrigger>
  </TabsList>

  <TabsContent value="cli">
    ```bash
    npx shadcn@latest add @termcn/code
    ```
  </TabsContent>

  <TabsContent value="manual">
    <Steps>
      <Step>
        Copy and paste the following code into your project.
      </Step>

      <ComponentSource base="ink" name="code" title="components/ui/code.tsx" />

      <Step>
        Update the import paths to match your project setup.
      </Step>
    </Steps>
  </TabsContent>
</CodeTabs>

Usage [#usage]

```tsx
import { Code } from "@/components/ui/code";
```

```tsx
<Code language="typescript">
  {`const greeting = "Hello, world!";\nconsole.log(greeting);`}
</Code>
```

Examples [#examples]

Multiline [#multiline]

<ComponentPreview base="ink" name="code-multiline" />

API Reference [#api-reference]

Code [#code]

| Prop                  | Type                                                                                         | Default    |
| --------------------- | -------------------------------------------------------------------------------------------- | ---------- |
| `children`            | `string`                                                                                     | `required` |
| `language`            | `string`                                                                                     | -          |
| `inline`              | `boolean`                                                                                    | `false`    |
| `borderStyle`         | `"single" \| "double" \| "round" \| "bold" \| "singleDouble" \| "doubleSingle" \| "classic"` | `"single"` |
| `showLineNumbers`     | `boolean`                                                                                    | `true`     |
| `lineNumberSeparator` | `string`                                                                                     | `"│ "`     |
| `keywordColor`        | `string`                                                                                     | -          |
| `stringColor`         | `string`                                                                                     | -          |
| `numberColor`         | `string`                                                                                     | -          |
| `commentColor`        | `string`                                                                                     | -          |
| `operatorColor`       | `string`                                                                                     | -          |
| `plainColor`          | `string`                                                                                     | -          |
