Stop Rebuilding UI

Shadcn.io is not affiliated with official shadcn/ui

React AI Code Block

React AI code block component with Shiki syntax highlighting, copy button, and dark mode support for chat interfaces

If your AI generates code (and let's be honest, that's like 90% of what people use AI for), you need a solid code block. This one uses Shiki under the hood, so you get proper syntax highlighting for pretty much any language—TypeScript, Python, Rust, whatever. It handles dark mode automatically by rendering both themes and showing the right one based on your app's theme class. There's a copy button built in because obviously users want to copy the code. The highlighting is async so it won't block rendering while Shiki does its thing, which matters a lot when you're streaming code in real-time. Just pass your code and language, and it looks good.

Code Block preview

Scroll to load preview

Installation

FAQ

Was this page helpful?

Sign in to leave feedback.