Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

Sparkline

sparkline

Shows a compact trend line for a small numeric series without full chart chrome.

Usage

Polyline (basic usage)

The default form is line. data can be passed as a pure digital sequence, with zero dependency on pure SVG.

tsx
<Sparkline data={[4, 6, 5, 8, 7, 10, 9, 12, 11, 14]} />

Emphasize the last point

highlightLast Draw an emphasis dot at the last point to highlight the latest value.

tsx
<Sparkline
  data={[4, 6, 5, 8, 7, 10, 9, 12, 11, 14]}
  highlightLast
  width={140}
  height={36}
/>

Form: Area / Column

variant switches line / area / bar; tone eats semantic colors or token variables.

tsx
<>
  <Sparkline data={series} variant="area" tone="var(--color-chart-2)" width={140} height={36} />
  <Sparkline data={dipSeries} variant="bar" tone="var(--color-chart-4)" width={140} height={36} />
</>

Inline in table

One trend per line, with renderTooltip (native <title>, zero JS, RSC safe) for point-by-point explanation.

IndicatorsCurrentRecent 8 period trends
Request volume QPS1,284No. 1 Period:8No. 2 Period:9No. 3 Period:7No. 4 Period:11No. 5 Period:10No. 6 Period:13No. 7 Period:12No. 8 Period:15
Average delay ms62No. 1 Period:80No. 2 Period:78No. 3 Period:74No. 4 Period:70No. 5 Period:66No. 6 Period:64No. 7 Period:63No. 8 Period:62
Error rate ‰0.4No. 1 Period:2No. 2 Period:1.5No. 3 Period:1.8No. 4 Period:1.2No. 5 Period:0.9No. 6 Period:0.6No. 7 Period:0.5No. 8 Period:0.4
Token consumption3.2MNo. 1 Period:1No. 2 Period:1.4No. 3 Period:1.2No. 4 Period:2No. 5 Period:2.6No. 6 Period:2.4No. 7 Period:3No. 8 Period:3.2
tsx
<Sparkline
  data={row.trend}
  variant="line"
  tone={row.tone}
  highlightLast
  width={96}
  height={22}
  renderTooltip={(v, i) => `${i + 1} period: ${v}`}
/>

When to use

Use Sparkline for a compact trend inside a table cell, KPI card, or list row. Use Chart when axes, legends, and interactive tooltips are required, or [Stat]/[Badge] for a single value.

Import

ts
import { Sparkline, normalize, linePath, areaPath, barRects } from "@hulianui/ui"

Props

NameTypeDefaultDescription
data*SparkDatum[]-Numbers or {x,y} points, using each y value.
variant"line" | "area" | "bar""line"Rendering mode.
widthnumber80Viewport width.
heightnumber24Viewport height.
tonestringvar(--color-primary)Semantic tone, CSS color, or CSS variable for stroke and fill.
highlightLastbooleanfalseDraws a marker on the final point.
minnumber-Explicit normalization lower bound.
maxnumber-Explicit normalization upper bound.
baselinenumber-Draws a horizontal dashed line at this value so the series has something to compare against instead of only a shape, typically last period's average, a target, or a pass mark. When neither min nor max is given, the baseline joins the normalization domain so it stays inside the viewport instead of being clipped.
baselineTonestringvar(--color-muted-foreground)Baseline color. Accepts the same values as tone (semantic color name, any CSS color, or a variable).
baselineLabelstring-Native tooltip text for the baseline, rendered as an SVG <title>.
classNamestring-Root class name.

Inherits SVGProps<SVGSVGElement> except data.

Slots

SlotTypeDescription
renderTooltip(value: number, index: number) => ReactNodeProduces an SVG <title> for each point.

Usage notes

  • Semantic names such as "primary" and "chart-2" are resolved to tokens. Handwritten SVG variables need the --color- prefix; see [[hulian-token-color-var-needs-color-prefix]].
  • Native <title> tooltips have browser-controlled delay and styling, trading customization for zero client JavaScript and RSC safety.

Related

ImageViewer · LiveProductCard · DiffStat · ScoreRing · Badge · Dot

Playground

<Sparkline
  data={[4, 6, 5, 8, 7, 10, 9, 12]}
  variant="line"
  highlightLast
  width={120}
  height={32}
/>
PreviousSankeyData DisplayNextFunnel

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Slots
    • Usage notes
    • Related
  • Playground