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

Charts & Stats

Sparkline

Charts & Stats

Sparkline React chart component for Tailwind CSS v4

Radial barStat Card
Live props
Appearance
type
tone
color
trendColor
invertTrend
curve
strokeWidth1.5px
showLast
showMinMax
reference
surface
Layout
width96px
height28px
Behavior
interactive
animated
Content
valueFormat
currency
locale
label
Code
import { Sparkline } from "@/components/ui/sparkline"

<Sparkline />
  1. Home
  2. Components
  3. Charts & Stats
  4. Sparkline
Pro

Sparkline React chart component for Tailwind CSS v4

v1.0.0·Added in 1.0.0

A React sparkline: a word-sized chart for table cells, list rows, KPI tiles and running text, as a line, an area, bars or win / loss ticks.

Read-only by default: the line draws in from the left the first time it scrolls into view and the last point pops in as a dot; screen readers hear the label and a summary ("from $8,200 to $12,480, +52.2%"). With interactive on, the sparkline becomes one tab stop: hover it with a mouse, or tap and drag sideways with a finger (vertical drags still scroll the page), and a compact readout above it shows the point's label and value while a hairline and a dot follow. The whole row height (8px above and below) is the touch target, a second tap on the same point or a tap outside clears it. From the keyboard, Tab focuses it, Left / Right walk the points, Home / End jump to the ends, Page Up / Page Down move by 10, Escape clears, and a polite live region reads each point. When the data changes the line and bars glide to their new shape. Reduced motion shows everything at once.

Sparkline is a Pro React chart component in the React chart and stat components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add sparkline, together with Chart kit, Trend badge, useControllableState, useLocale, Motion presets and 3 more and the npm packages motion, d3-shape and d3-scale.

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 sparkline

Sparkline is part of Pro, with 298 more Pro items: $8 a month or $150 once. 14-day refund before you download any Pro item. See plans

Usage

Import Sparkline from @/components/ui/sparkline.

import { Sparkline, SparklineWithValue } from "@/components/ui/sparkline"

const revenue = [8200, 8650, 8400, 9100, 9480, 9230, 10150, 10600, 10380, 11420, 11900, 12480]

export function ClientRow() {
  return (
    <div className="flex items-center justify-between gap-3">
      <span className="text-sm font-medium">Tech Solutions Inc.</span>
      <Sparkline
        data={revenue}
        valueFormat="currency"
        locale="en-US"
        label="Revenue, last 12 weeks"
        interactive
      />
      <SparklineWithValue
        data={revenue}
        type="area"
        valueFormat="currency"
        locale="en-US"
        layout="responsive"
        min={0}
        max={16000}
      />
    </div>
  )
}

Props

  • data*
    (number | null)[] | { value: number | null; label?: string; date?: string }[]

    The values, oldest first. Rows can carry a label ("Week 39") or an iso date for the readout; null leaves a gap in the line.

  • typedefault "line"
    "line" | "area" | "bar" | "win-loss"

    line, line over a soft fading fill, bars from zero, or win-loss: equal ticks up for positive and down for negative values (streaks, daily goals). Bars fall back to a line above 120 points.

  • widthdefault 96
    number

    Width in px. 0 fills the container (the parent needs a width, e.g. a grid cell or a flex-1 box).

  • heightdefault 28
    number

    Height in px. 28 reads well in a phone row; 16 sits inside a line of text.

  • tonedefault "neutral"
    "neutral" | "brand" | "success" | "warning" | "danger" | "info"

    The stroke and fill color. neutral is the ink (black in light mode, white in dark mode).

  • colordefault ""
    string

    Any CSS color, a palette slot ("series-3") or a tone name. Replaces tone and trendColor.

  • trendColordefault false
    boolean

    Color by the direction from the first to the last value: success when it rose, danger when it fell, the ink when flat. Win-loss paints wins green and losses red.

  • invertTrenddefault false
    boolean

    Down is good (costs, churn, response time): a fall turns green under trendColor and reads as positive (data-intent).

  • curvedefault "monotone"
    "monotone" | "linear" | "natural" | "step"

    How the line joins the points. monotone never overshoots a value; step suits counts that jump.

  • strokeWidthdefault 1.5
    number

    Line width in px, with round caps and joins.

  • showLastdefault true
    boolean

    A 5px dot on the last point, ringed in the surface color. For bars, the last bar keeps the full color and the others soften.

  • showMinMaxdefault false
    boolean

    Small hollow dots at the lowest and the highest point (bars: those bars in full color).

  • referencedefault "none"
    "none" | "first" | "average" | "zero"

    A dashed hairline at the first value, the average or zero (zero widens the range to include it).

  • surfacedefault ""
    string

    The color behind the sparkline, used for the rings around dots. Empty is the surface token.

  • min
    number

    Lower bound of the value range; the data's minimum when unset. Share min and max across the rows of a table so the sparklines compare.

  • max
    number

    Upper bound of the value range; the data's maximum when unset. The Clients table example shares one range across rows.

  • interactivedefault false
    boolean

    Focusable and inspectable: hover, tap, drag or arrow keys show each point in a compact readout pinned above the sparkline.

  • activeIndex
    number | null

    The inspected point, controlled (with onActiveIndexChange), so a value next to the sparkline can follow the scrub.

  • defaultActiveIndexdefault "null"
    number | null

    The inspected point on mount, uncontrolled; null starts with no readout. Needs interactive.

  • onActiveIndexChange
    (index: number | null) => void

    Called when a point is inspected or the readout clears.

  • valueFormatdefault "number"
    ChartValueFormat = "number" | "compact" | "currency" | "percent"

    How values print in the readout and the accessible summary ("$12,480" with currency and en-US).

  • currencydefault "USD"
    string

    ISO 4217 code for valueFormat="currency", printed with its narrow symbol.

  • formatValue
    (value: number, context: "tooltip" | "label" | "value") => string

    Full control over printed values, e.g. v => `${v} orders`.

  • localedefault ""
    string

    Intl locale for values and dates. Empty follows the UIProvider, then the page.

  • labeldefault ""
    string

    The accessible name, e.g. "Revenue, last 12 weeks". A summary of the first and last value and the change is appended.

  • animateddefault true
    boolean

    Draws in the first time it scrolls into view (0.6s), the last dot pops in after it; data changes glide either way. Off under reduced motion.

  • labels
    { summary?: (first: string, last: string, change: string) => string; empty?: string; point?: (index: number, count: number) => string; inspectHint?: string }

    Screen reader strings. Defaults "from {first} to {last}, {change}", "No data", "{n} of {count}" and the arrow-key hint. Pass only the keys you translate.

  • classNames
    Partial<Record<"svg" | "line" | "area" | "bar" | "last" | "reference" | "tooltip", string>>

    Extra classes for the inner parts.

  • className
    string

    Extra classes for the root, e.g. "align-[-0.2em]" inside text. Other props (id, data-*, aria-*, events) spread onto the root span.

Parts

  • DEFAULT_SPARKLINE_LABELS

    constant

    The English screen reader strings: the summary "from {first} to {last}, {change}", "No data", "{n} of {count}" and the arrow-key hint.

  • SparklineWithValue

    component

    A sparkline with the current value and a TrendBadge, for table cells and list rows. value = the last point (the inspected point while scrubbing); delta = the % change first -> last (with deltaFormat "number" / "currency": last - first); deltaFormat = "percent"; badgeVariant = "ghost"; badgeSize = "sm"; showDelta = true; layout "inline" (default) | "stacked" (value and badge over the sparkline) | "responsive" (stacked below 640px); badgeLabels for the badge's spoken text; classNames { sparkline, value, badge, meta, ...the Sparkline slots }. className and style go to the wrapper, every other prop to the Sparkline, and activeIndex / onActiveIndexChange work the same. Props: SparklineWithValueProps.

Examples

Clients table

SparklineWithValue with shared min / max so rows compare; stacked under the value on phones.

Types

line, area, bar and win-loss, filling their tiles (width 0).

Trend colors

trendColor paints by direction; invertTrend makes falling costs green and rising returns red.

Inside text

64 x 16 sparklines on the text baseline (align-[-0.2em]).

Scrub to read

interactive, reference="average" and min / max dots; the big number follows activeIndex.

KPI card footer

type="area" at 48px filling the card, inspectable.

Live data

Data updates glide on a smooth spring instead of redrawing.

Edge cases

One value, all equal, gaps, no data, negatives and 365 points.

Dependencies

motiond3-shaped3-scalechart-kittrend-badgeuse-controllable-stateuse-localemotionnumber-formattonesui-config

Files

  • components/ui/sparkline.tsx

FAQ

Is the React Sparkline chart component free?

The preview, props and docs are free; copying the source needs a Pro plan. See plans.

How do I install Sparkline?

Run npx wingo-ui@latest add sparkline. It also adds the Wingo UI items it builds on (Chart kit, Trend badge, useControllableState, useLocale, Motion presets and 3 more) and the npm packages motion, d3-shape and d3-scale. With shadcn, add the @wingo-ui registry with your API key, then run npx shadcn@latest add @wingo-ui/sparkline.

See also

Chart kitlibTrend badgeLine chartAnimated CounterStat Card

Used in

Admin Dashboard Page

More React chart and stat components

LeaderboardArea chartBar chartDonut chartFunnel chartRadar chart
All 16 React chart and stat components

Articles using this component

  • Shadcn KPI Cards: Deltas, Sparklines and Goal Bars

    Component guides · Nov 6, 2026 · 9 min read

  • React Sparkline: Table Cells, KPI Tiles, Delta Chips

    Component guides · Oct 19, 2026 · 9 min read

PreviousRadial barNext Stat Card

Weekly revenue

Northwind CRM · last 12 weeks

TI
Tech Solutions Inc.New York · Emma Carter
$12,480+52.2%Up 52.2%

draw-in: on · interactive: off