Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Data Display

Code Block

Data Display

Code Block React component for Tailwind CSS v4

Calendar ViewComment Thread
Live props
Content
code
language
filename
copyLabel
copiedLabel
Appearance
accent
mode
size
radius
background
showFrame
showHeader
showLineNumbers
Behavior
showCopyButton
copyResetMs1800ms
Layout
wrap
maxHeightNo limit
Code
import CodeBlock from "@/components/ui/code-block"

<CodeBlock />
  1. Home
  2. Components
  3. Data Display
  4. Code Block
Free

Code Block React component for Tailwind CSS v4

v1.0.1·Updated in 1.2.1

A React code block with syntax highlighting, line numbers, highlighted lines and a copy button, themed from a single accent color.

Pick an accent to re-shade the whole block from that one color: keywords, strings, comments, selection and the highlighted-line wash are all tints of it. Hit the copy button to put the code on the clipboard and watch the icon spring into a check. Long lines scroll sideways inside the block, and the code area is focusable so arrow keys scroll it too.

Code Block is a free React component in the React data display components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add code-block, together with UIProvider and the npm packages lucide-react, motion and prism-react-renderer.

Add to a project

Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add code-block

Usage

Import CodeBlock from @/components/ui/code-block.

import CodeBlock from "@/components/ui/code-block"

export function Demo() {
  return (
    <CodeBlock
      code={`const greet = (name: string) => \`Hello, \${name}!\``}
      language="ts"
      accent="#F75001"
      filename="greet.ts"
      highlightLines={[1]}
      className="max-h-96 w-full max-w-xl"
    />
  )
}

Props

  • code*
    string

    The source code to render. Leading blank lines and trailing whitespace are trimmed.

  • languagedefault "tsx"
    string

    Prism language id, e.g. "tsx", "css", "json", "python". Also shown in the header when there is no filename. Bundled: markup, jsx, tsx, js, ts, css, json, python, go, rust, sql, yaml, graphql, swift, kotlin, cpp, markdown.

  • accentdefault "#F75001"
    string

    Any hex color. The whole theme is shades of it: keywords take the accent itself, strings, numbers and functions are lighter or darker tints, and selection and highlighted lines get a soft wash of it.

  • modedefault "auto"
    "auto" | "dark" | "light"

    Color scheme. Auto follows the page theme (html dark/light class, data-theme, or OS preference). Pass dark or light to pin a palette: dark puts light tints of the accent on a dark surface, light flips the ramp.

  • filenamedefault ""
    string

    Filename or path shown on the left of the header. Falls back to the language id when empty or omitted.

  • sizedefault "md"
    "sm" | "md" | "lg"

    Code at 12 / 13 / 14px on 20 / 24 / 28px lines, with a 36 / 40 / 44px header.

  • radiusdefault "md"
    "none" | "sm" | "md" | "lg" | "full"

    Corner radius of the frame: 0, 12, 16 or 24px; full falls back to 24px.

  • backgrounddefault ""
    string

    Any CSS color for the framed surface. Empty uses the neutral surface of the mode (near black or near white). Token colors are tuned for 4.5:1 on those defaults, so pair a dark background with mode dark and a light one with mode light.

  • showFramedefault true
    boolean

    Toggles the outer frame: background, border, rounded corners, and header. Turn off to render nothing but the highlighted code.

  • showHeaderdefault true
    boolean

    Toggles the header bar. When hidden, the copy button floats over the top-right corner instead. Ignored when showFrame is off.

  • showLineNumbersdefault true
    boolean

    Toggles the line-number gutter.

  • showCopyButtondefault true
    boolean

    Toggles the copy-to-clipboard button.

  • wrapdefault false
    boolean

    Wraps long lines inside the block instead of scrolling sideways; line numbers stay on the first row of each line.

  • maxHeightdefault 0
    number

    Caps the block's height in pixels and scrolls the code inside it. 0 means no limit.

  • copyLabeldefault "Copy code"
    string

    Accessible name of the copy button.

  • copiedLabeldefault "Copied"
    string

    Accessible name of the copy button right after copying.

  • copyResetMsdefault 1800
    number

    How long the check stays on the copy button, in milliseconds.

  • highlightLines
    number[]

    Optional 1-based line numbers to highlight with a soft accent wash. Off when omitted.

  • className
    string

    Extra classes merged onto the root element (data-slot="code-block"). Use it for width and max-height; the code area scrolls inside.

Examples

Highlighted lines

Pass highlightLines to wash a few lines in the accent, here the request and its error path.

Long file with line numbers

maxHeight caps the block at 260px and scrolls the code inside; line numbers help when you point at a line.

API response in light mode

mode light pins the light palette whatever the page theme, here with a green accent and the small size.

Wrapped query

wrap breaks a long line inside the block instead of scrolling it sideways.

Inside a docs paragraph

size sm without line numbers, wrapped to fit: a short snippet that sits in running text.

Dependencies

lucide-reactmotionprism-react-rendererui-config

Files

  • components/ui/code-block.tsx

FAQ

Is the React Code Block component free?

Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.

How do I install Code Block?

Run npx wingo-ui@latest add code-block. It also adds the Wingo UI item it builds on (UIProvider) and the npm packages lucide-react, motion and prism-react-renderer. With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/code-block.json.

See also

Copy ButtonDiff ViewerJSON ViewerMarkdownLog Viewer

Used in

Schema BuilderMarkdownFile SystemTool Call TimelineError PagesDocs Home PageIntegrations Page

More React data display components

Comment ThreadContact cardDescription ListFile ListFolderGantt
All 23 React data display components

Articles using this component

  • React Terminal Component: Typing Animation Without Jank

    Component guides · Nov 6, 2026 · 8 min read

  • Nextjs llms.txt: Generate llms-full.txt and .md Pages

    Building UI with AI agents · Oct 16, 2026 · 10 min read

  • React Diff Viewer in React 19: Split, Unified, Word Diffs

    Component guides · Oct 16, 2026 · 9 min read

  • React JSON Viewer: Search, Copy Paths and Big Payloads

    Component guides · Oct 16, 2026 · 9 min read

PreviousCalendar ViewNext Comment Thread
orbit.tsx
1import { useSpring, animated } from "motion/react";
2
3type OrbitProps = {
4 radius?: number;
5 speed?: number;
6};
7
8export function Orbit({ radius = 120, speed = 1 }: OrbitProps) {
9 const angle = useSpring(0, { stiffness: 80, damping: 20 });
10
11 const x = Math.cos(angle.get()) * radius;
12 const y = Math.sin(angle.get()) * radius;
13
14 return (
15 <animated.div
16 style={{ x, y }}
17 className="size-4 rounded-full bg-current"
18 />
19 );
20}