Interactive Code Snippet Showcase
A code-editor-styled feature section: a sidebar lists features with a title and short description, and clicking one swaps the right-hand panel to that feature's code sample, complete with a filename tab, traffic-light window dots, line numbers, and manual span-based token coloring.
Docs
Installation
A real shadcn registry command, not a copy-paste stand-in: it fetches this block plus its dependencies and any missing npm packages, and installs them straight into your project.
npx shadcn add https://staaarter.com/r/interactive-code-snippet-showcase.jsonPrefer not to use the CLI? Copy the source from the Code toggle above into src/components/blocks/feature/feature98.tsx instead.
Usage
The file also exports feature98Demo, the exact props behind the preview above. Spread it to get a working section in one line, then replace it with your own data.
import { Feature98, feature98Demo } from "@/components/blocks/feature/feature98"; export default function Page() { return <Feature98 {...feature98Demo} />; }
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| eyebrow | string | undefined | Small label above the heading; omitted entirely when unset. |
| heading | ReactNode | none | Section heading. |
| description | string | undefined | Supporting copy under the heading. |
| items | CodeFeatureItem[] | none | Feature entries; the first is selected by default. |
| className | string | undefined | Extra classes for the outer section element. |
Types
type CodeToken = { text: string; kind?: "keyword" | "string" | "comment" | "function" | "plain"; }; type CodeFeatureItem = { title: string; description: string; filename: string; lines: CodeToken[][]; };
Behavior notes
- Real client-side state: clicking a feature in the sidebar sets it as the active item via useState, which swaps the filename tab and the rendered code lines on the right.
- "use client" component, so its demo props live in the sibling feature98.demo.tsx file per this repo's client/demo-file-split rule, not in feature98.tsx itself.
- Syntax coloring is manual: each code line is an array of tokens with an optional `kind`, mapped to a fixed table of semantic Tailwind classes (text-primary for keywords, text-chart-3 for strings, text-chart-2 for function names, muted italic for comments). There is no real syntax-highlighting library involved.
- The window chrome (three dots, filename tab) is purely decorative styling, not a functional editor.
- The sidebar becomes a horizontally scrolling tab strip on small screens and a vertical list on large screens; item descriptions are hidden on small screens to keep the tab strip compact.
- The first feature is selected by default on mount.
More Feature Blocks
View all →Full-Bleed Workspace Band
Two-column header above a full-bleed image band with a live view switcher, closing on three numbered captions.
Center-Line Journey Timeline
Vertical hairline timeline alternating stages either side, dropping a phone frame on one step.
Figure-Led Evidence Rows
Tall image with a floating before-and-after card, leading into oversized-figure evidence rows.
Staircase Asset Trio
Three image tiles stepping down the page in a staircase, each floating a different live asset.
Sticky Reference List
Sticky heading column beside three labelled groups of checked capabilities, closing on a footnote.
Day Timeline Rows
Hairline rows walking through one working day, stamped with time and a live approval card inline.