Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Live Code Playground Showcase Features Block for React

A code window in a framed figure with three language tabs, a copy button, and a Run button that shows a spinner and then a typed response panel, for a typed SDK.

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 live code playground for React with Base UI. A left-aligned header says "Call it from any language". A framed figure (its lines run past the corners with + marks) holds one window split in two with a hairline. At the start, the same SDK call in TypeScript, Python or Go behind tabs, with a copy button for the code on show; at the end, the response panel, where Run shows a spinner for a moment and then the typed result: how it's declared and each field with its type in the language you picked. The window follows your theme: the code is plain weights of the page's own colours, with no syntax palette. On a phone the response sits under the code. It's built from Tabs, Copy Button, Shine Button, Spinner and Guides. For SDKs, API platforms and developer tools.

FAQ

How do I change the samples?

Edit LANGUAGES: each is built with languageOf from an id, a label, a file name, how the result is declared and its lines. A line is made of kw, txt, qs and cm tokens: keywords are bold, strings and comments muted. FIELDS holds the result's fields, with each field's name and type in every language, in the same order as LANGUAGES.

Does Run call a real API?

No. It shows a spinner for WAIT milliseconds and then the canned result. To call something real, replace the timeout in run with your request and set the result from its answer. The call's state is announced in a polite status line: "Running events.track", then "Response received, 201 Created".

What does the copy button copy?

The plain text of the language on show, without line numbers or styling. It tells screen readers when the text is on the clipboard, and says so too if the browser refuses, as on a page not served over HTTPS.

Why isn't the code window dark?

It follows your theme, light or dark, like the rest of the page. The code uses the page's own colours at different weights instead of a syntax palette, so it holds up in every preset. A real terminal would be the only content worth forcing dark.

How do the tabs work by keyboard?

Tab reaches the language tabs and the arrow keys move between them; the code panel is a tab stop too, so a long line can be scrolled with the arrow keys. The tab state lives in the block, so the response panel and the copy button follow it. The tabs are controlled with value and onValueChange, which receives the new value.

How does it fit on a phone?

The response panel moves under the code, and the file name hides to leave room for the tabs and the copy button. Code lines scroll sideways inside their panel instead of wrapping, and the window keeps one height across the three languages so switching never moves the page.

  • Pro

    Split API Playground Hero

    Code and terminal

    A showcase hero for a payments API: a headline, a Shine Button, a second action and three ticks, then a wide playground under its own rule: a POST request beside the 200 response, each JSON body writing itself out.

  • Pro

    Three alternating bands for a typed event-stream client, each pairing a sentence with a code window that draws a different artifact: a call with its autocomplete popover, a config file with one line marked, and a command's output.

  • Pro

    An endpoint reference for an e-signature API: six rows with a method, a path, a sentence and a status, each opening to a request and a response snippet.

  • Pro

    A features section for a command-line tool: four tabs (Deploy, Build, Test, Log) swap a dark terminal session typed out once, with commands, output and exit status, above three cells with overshoot that each carry a small chip.

  • Pro

    A features section for a release tool: a line tab switch (Plan, Ship, Review) that swaps one split band, with a drawing flush to the start rail and the copy on the end side.

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