mirror of
https://github.com/vercel/ai-elements.git
synced 2026-09-14 19:48:26 +08:00
24 lines
536 B
TypeScript
24 lines
536 B
TypeScript
"use client";
|
|
|
|
import { CodeBlock, CodeBlockCopyButton } from "@repo/elements/code-block";
|
|
|
|
const code = `function MyComponent(props) {
|
|
return (
|
|
<div>
|
|
<h1>Hello, {props.name}!</h1>
|
|
<p>This is an example React component.</p>
|
|
</div>
|
|
);
|
|
}`;
|
|
|
|
const Example = () => (
|
|
<CodeBlock code={code} language="jsx">
|
|
<CodeBlockCopyButton
|
|
onCopy={() => console.log("Copied code to clipboard")}
|
|
onError={() => console.error("Failed to copy code to clipboard")}
|
|
/>
|
|
</CodeBlock>
|
|
);
|
|
|
|
export default Example;
|