Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Split Layout Code Diff Hero Block for React

A showcase hero for a code review tool: a centred headline, a Shine Button, a second action and three ticks over a wide pull request window in a hairline frame, with a diff whose changes play out line by line.

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 hero with a pull request window below the copy, for React with Base UI. The section sits on the page's drafting lines: two solid rails at the edges of the page column that continue into the blocks above and below, and a rule along its top edge that runs to the page's edges, with a plus mark on each crossing. Every line is the theme's border colour, so it follows any preset. The header is centred: an announcement pill links to Kestrel 3.0, a code review tool, then a headline, a subtitle, a primary ShineButton and an outline Button, both links, and three ticks. Under it a wide window sits in a hairline frame with plus marks on its corners: a title bar with the pull request's name, the changed files in a list beside the diff, the open file's name with its added and removed counts, and the diff, which plays out once it scrolls into view: the removed lines tint and strike through, then the added lines slide in one after the other, in your theme's colours. Under the diff a reviewer's comment explains the change. For AI code review tools, refactor assistants, pull request platforms and any developer product that explains itself through before-and-after code.

FAQ

How do I show my own change?

Edit DIFF and FILE at the top of the file. DIFF is written as a unified diff, one line per line: start a line with + to add it, - to remove it, or a space to leave it as context. The counts in the diff header are worked out from those signs, so they always match the lines shown. FILES is the list of changed files and TITLE the window's title.

How does the diff animate?

It's our DiffText. Once the window is a quarter in view, each removed line tints and strikes through, then each added line slides in, a fifth of a second apart, all in CSS. It plays once. With reduced motion on, the finished diff is simply there, and the copy and the window appear in place instead of fading in.

Can I feed it a real diff?

Yes: the output of git diff for a single hunk works as is, without the @@ header line. Pass it as text and keep the hunk short, ten lines or so, so the window stays in proportion with the copy above it.

How are the lines and the frame drawn?

The page column has Guides bleed marks="top" rules="top": two side rails and one top rule with a plus on each crossing. The frame is Guides extend="sm" marks="corners" on the box around the window, so its lines overshoot the corners a little. The window has its own padding between the frame and its edge, and the column keeps its bottom padding, since the figure is the last thing in it.

How does a screen reader read the diff?

The window is a figure named "Suggested change to auth.ts", and the code is real text. Removed lines are del elements and added lines ins elements, each read with "Removed" or "Added" before it, and the counts read "+5 lines added" and "−2 lines removed". The reviewer's comment is a paragraph. The title bar and the list of files are decoration and hidden. The headline is the block's one h1.

What happens to long lines on a phone?

The file list drops out below md and the diff keeps the window's width. Code lines don't wrap: the diff scrolls sideways inside its window instead, and the page itself never does. The scrolling area is in the tab order with a focus ring, so keyboard users can scroll it with the arrow keys too. The ticks stack, and the Shine Button is on the first screen.

  • Pro

    A showcase hero for a merge queue: a two-part header with a Shine Button, over a ruled band where a pull request page rises and fades out, with its diff, reviewers, checks and queue position.

  • 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 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

    A reverse split hero for a code host: a commit history drawn as a branch graph in a hairline frame on the start side, then an announcement link, the headline, a Shine Button and three ticks.

  • 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 split hero for an AI assistant: a headline, a Shine Button and a second action beside a chat app sketched in skeleton bars that runs off a tinted panel, closed by a band of three feature cells.