# Terminal Clear Example

> Example implementation of terminal clear.

A shadcn/ui block from the [@ai-elements](https://ai-sdk.dev/elements) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/ai-elements/example-terminal-clear).

- Page, with a live preview: https://shadcn.exchange/r/ai-elements/example-terminal-clear
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/ai-elements/example-terminal-clear-light-ec947cc0d41f55c9.png
- Registry item: https://ai-sdk.dev/elements/api/registry/example-terminal-clear.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://ai-sdk.dev/elements/api/registry/example-terminal-clear.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `https://elements.ai-sdk.dev/terminal.json`

## Files

### `registry/default/examples/terminal-clear.tsx`

```tsx
"use client";

import { Terminal } from "@/components/ai-elements/terminal";
import { useCallback, useState } from "react";

const initialOutput = `\u001B[36m$\u001B[0m npm run build
Building project...
\u001B[32m✓\u001B[0m Compiled successfully
\u001B[32m✓\u001B[0m Bundle size: 124kb`;

const Example = () => {
  const [output, setOutput] = useState(initialOutput);

  const handleClear = useCallback(() => setOutput(""), []);

  return <Terminal onClear={handleClear} output={output} />;
};

export default Example;
```
