Color
Pass any valid CSS color, including design-system tokens.
vue
<template>
<NbSparkline :data="series" color="var(--nb-c-success)" />
</template>Props
| Prop | Type | Default | Description |
|---|---|---|---|
data | number[] | required | Values to plot. Needs at least 2 entries to render. |
color | string | var(--nb-c-primary) | Line and gradient color. Any CSS color string. |
height | number | string | 40 | SVG height. Numbers are interpreted as pixels. |
width | number | string | '100%' | SVG width. Numbers are interpreted as pixels. |
strokeWidth | number | 1.5 | Line thickness in pixels (non-scaling-stroke). |
fill | boolean | true | Render the gradient area under the line. |
smooth | boolean | true | Use bezier smoothing between data points. |
animate | boolean | false | Draw the line in from the left on first render and on data change. |
Entrance animation
animate draws the line, and the fill under it, in from the left when the sparkline first renders and again when its data changes. It is off by default and is switched off entirely under prefers-reduced-motion: reduce.
vue
<NbSparkline animate :data="values" />Notes
- The component renders a fixed internal
viewBoxof0 0 100 30and stretches it viapreserveAspectRatio="none"to match the requested width and height. Stroke width stays visually constant because the line usesvector-effect="non-scaling-stroke". - The gradient fades from
colorat 30 % opacity at the top to fully transparent at the bottom. - Each instance generates a unique gradient id via Vue's
useId(), so multiple sparklines on the same page do not collide. - A small vertical padding (~8 % of height) is reserved so the line never touches the top or bottom edge.