Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Code Window Hero Block for React

A split hero for an API client generator on solid rails: a headline and a Shine Button beside a code window whose snippet comes in token by token, in a hairline frame with + marks.

Framework
UI library

Preview

Preview width

Installation

Part of Pro
Pro unlocks the code and one-line install of every Pro button and text effect, plus the MCP for your AI editor.
Have Pro already? Sign in to open it.Opens here as soon as you're Pro.

Overview

A split hero with a code window as its anchor, shown here for Quarry, a generator of typed API clients. At the start, an announcement link, a headline, a sentence, a Shine Button and an outline Button. At the end, a code window with traffic-light chrome, an orders.ts tab, line numbers and a short TypeScript snippet coloured like an editor, which comes in token by token as it scrolls into view. The window sits on a tinted stage inside a hairline frame with + marks on its corners, between the same side rails as the pricing blocks, under the page's top rule. The block follows your theme, and so does the window (it is not forced dark). It's built from Announcement, Badge, Status, Guides, Shine Button, Button and Syntax Text, with CSS transitions for the entrance. For developer tool landing pages, framework homepages, SDK and library sites, and any product where showing code signals quality.

FAQ

How do I change the code in the window?

Edit CODE at the top of the file: it's the snippet as you'd write it, its lines and indentation kept. Syntax Text colours it as it renders (comments, strings, numbers, keywords and punctuation) and numbers its lines with lineNumbers. FILE is the name in the tab, and it also names the code for screen readers. Keep lines to about 35 characters so a phone shows them whole. For another language than JavaScript or TypeScript, pass Syntax Text that language's keywords.

Does the window follow my theme?

Yes. Nothing sets a dark scope: the stage is a bg-muted/40 tint, the window a raised bg-card with a border and a deep shadow, and the code colours come from your theme's tokens, so the block is light in a light theme and dark in a dark one. If you want an always-dark window, put the dark class on the window only, and say so in a code comment.

Can screen reader and keyboard users read the code?

Yes. The snippet is real text in a pre, read as written and selectable; the window's dots and tab are hidden from assistive tech, and the line numbers stay out of a copy and out of the reading. The code sits in a region named after the file that Tab can reach, so a line wider than the window can be scrolled with the arrow keys. The headline is the page's h1, and with reduced motion nothing fades or rises: the text, the buttons and the code are there from the start.

How does it fit on a phone?

The columns sit side by side from the lg breakpoint. Below it the text comes first, both buttons end on the first screen, and the framed window follows, with the code at 11px. A line longer than the window scrolls sideways inside it rather than wrapping, so every line stays beside its number.

When should I use a code window instead of a terminal hero?

Use the code window when what it's like to write with your product is the pitch: a few lines of real usage tell developers more than a feature list. Use a terminal hero, such as Dark Terminal Copy, when installing or running it is the point.

  • Pro

    Split Code Preview Hero

    Code and terminal

    A reverse split hero for a job-queue SDK: a code window in a hairline frame with a copy button, beside the headline, three checks and two calls to action.

  • Pro

    A split hero for a project scaffolder: text with a Shine Button and three stats on a ruled row, and a terminal in a hairline frame that shows the install command with a copy button and what it set up.

  • Pro

    A split hero for an API: the headline, a Shine Button and three ticks beside a dark terminal with a request, a status and a JSON response that writes itself out, above a band of three figures.

  • Pro

    Install Command Hero

    Code and terminal

    A compact centred hero for an open-source library with a star count pill, an install command to copy, a Shine Button, a GitHub star button and a ruled band of the repository's stats at the foot.

  • Pro

    A compact centred hero for a web framework: an install command with a copy button, two calls to action and a band of three stats.

  • Pro

    A compact, centred hero for a design tool on solid rails: concentric rings breathe behind a headline, a Shine Button and an outline button, over a ruled band of three stats.