SwipeUI

Sparkline

A compact trend that can be decorative or explored.

npx @swipeui/cli add sparkline
Variant
Preset
Material
Scheme
Feel
Interactive web demo. Native materials, gestures and system presentation differ on device.

When to use it

  • A compact trend that can be decorative or explored.
  • Small trends inside rows and tiles, such as a watchlist or a market ticker; see Line chart for those layouts.

When not to use it

  • Use Metric card when one headline number answers the question without a full plot.

Installation

Installs with a Pro licence

Everything on this page is public except the source. Founder pre-sale opens around 5 January 2027.

Usage

import { Sparkline } from '@/components/swipeui/chart/sparkline';

<Sparkline label="Users" data={[{ id: "mon", x: 1, y: 120 }, { id: "tue", x: 2, y: 150 }]} decorative />

Examples

kpi, interactive. App and public preview use the same original scenario data. Range and feature controls stay outside the component.

Small trends inside rows and tiles, such as a watchlist or a market ticker, use referenceValue and areaStyle="fade". Those finance layouts live on Line chart.

Settings

PropDefaultBehaviour
tooltipPlacementplotPlace inspection inside the plot or above it.
tooltipWidth184Readout width bounded by the visible plot.
renderTooltipdefault cardCustom inspection content; streamgraph supplies a coloured multi-row comparison.
dismissOnOutsidePresstrueClear floating inspection when touching outside a chart under ChartInteractionProvider.
smoothtrueSmooth curves between observations.
trendColortrueInfer green growth / red decline from first and last valid observations.
data—Ascending real observations, oldest first.
areafalseWash below the line.
areaStylewashwash for an even tint or fade to fade it out toward the bottom.
referenceValue—A dashed comparison level, such as the previous close.
endpointtrueMark the latest real observation.
decorativefalseHide from assistive technology inside an already described KPI.
color—Caller colour override; defaults to chart-1.
label—Short accessible chart name.
summary—Written description of the pattern, in the caller's words.
loadingfalseShow shimmer placeholders and expose the busy state.
invalidfalseExplicitly unavailable dataset.
interactivetrueEnable plot interaction and accessible value stepping.
tooltiptrueCompact floating value card over the selected observation.
legendtrueShow a labelled series/category key.
hapticstrueTick when a different observation is selected.
revealtrueReveal geometry on first appearance.
animateDatatrueMorph data changes; resize snaps.
activetruePause ambient effects on hidden routes.
selectedId—Controlled observation ID; null clears selection.
defaultSelectedIdnullInitial observation when uncontrolled.
onSelectionChange—Called only when semantic selection changes.
locale—Device locale unless overridden.
formatValue—Override value formatting.
messages—Translatable built-in strings.
motion—Inherited SwipeUI motion feel.
height64Plot height in points; text flows outside it.
className—Root class escape hatch.
style—Root native layout escape hatch.
testID—Stable root identifier.

Accessibility

The plot exposes its name, summary and original values. Accessible value stepping and labelled keys supplement touch. Decorative marks do not repeat the readout. Reduced motion removes geometry travel.

Layout and data

Measure from the parent; let labels and keys wrap. Use stable IDs. Missing observations are gaps, not zeros. Parts of a whole and flows require nonnegative finite values. Native runtime, screen-reader, haptic and device-performance checks remain pending.

Presentation

KPI puts the smooth directional trend in Metric Card's backdrop slot, behind the number and text and above the card fill, so the Glass material never covers it. Both variants use a signed top-right change chip, green growth or red decline, and reveal from left to right. Interactive inspection floats above the line. Screen readers can still read the original observations as a table.

Outside dismissal

Wrap the app or chart screen in ChartInteractionProvider from @/components/swipeui/lib/chart-core. It observes native touches without taking the responder; controls keep their normal behaviour. dismissOnOutsidePress={false} retains a caller-managed selection. Browser demonstrations use pointer observation and Escape.

Behavior and gestures

  • Smooth directional trends reveal from left to right; interactive inspection floats above the plot. KPI examples put the line in MetricCard's backdrop slot, behind the metric and above its fill.
  • Optional dashed reference level (referenceValue) and a fading area (areaStyle), each independent.

Accessibility

  • The chart has a written summary and named values. Decorative SVG geometry is hidden from assistive technologies.
  • Value stepping, labelled legends and text readouts supplement colour. Native screen-reader runtime validation remains pending.

Motion

  • Uses the morph, select and ambient motion roles, so it follows your app's feel. Pass motion to tune this one instance.
  • Geometry transitions use the shared morph role; reduced motion swaps immediately.
  • Ambient effects pause offscreen and in the background.

Performance

  • Display geometry is bounded for time series; selection retains original data. Native device performance is not yet verified.

Notes for AI

  • Use stable IDs and caller-owned data/state. Provide an accessible label and a useful written summary.
  • Put a background trend in MetricCard's backdrop slot so Glass never covers it; keep MetricCard sparkline content decorative.

Compatibility

Runs onSupported
Expo SDK 57Yes
Expo SDK 58Yes
React Native CLI (with Expo modules)Yes
Expo GoYes
iOSYes
AndroidYes

This table describes API support and static bundle checks. Native runtime, device accessibility and bare Uniwind compatibility remain pending.

Related items