/
Dark Light
System
Default LBBW Jira Confluence Source Code
Share
Playground

Sparkline

<afp-sparkline> Since 1.9.0 stable This component uses the light DOM, so its markup and styles are part of the regular document flow.

A compact sparkline chart for displaying data trends inline.

Examples #

Appearance #

Use the appearance attribute to control the fill style.

solid
gradient
line

Trend #

Use the trend attribute to apply semantic coloring.

neutral
positive
negative

Curve #

Use the curve attribute to control how data points are connected.

linear
natural
step

Inline usage #

Sparklines default to height: 1em so they naturally fit within text.

Revenue this quarter is up 18% compared to last quarter.

Custom colors #

Use CSS custom properties to override the line and fill colors independently.

Properties

Learn more about properties.

Name Description Reflects
data
Space-separated numeric values to plot (minimum 2 required to render).
Type string
Default ''
label
Accessible label announced by screen readers in place of the SVG image.
Type string
Default ''
appearance
Visual fill style of the chart area.
Type
AfpSparklineAppearance
Name Description
SOLID
Filled area beneath the line with a solid, semi-transparent color.
GRADIENT
Filled area beneath the line with a top-to-bottom opacity gradient.
LINE
Stroke only — no fill beneath the line.
AfpSparklineAppearance
Default AfpSparklineAppearance.SOLID
trend
Semantic trend direction — applies the matching design-system color.
Type
AfpSparklineTrend
Name Description
NEUTRAL
No directional meaning — uses the brand color.
POSITIVE
Upward / favorable trend — uses the success color.
NEGATIVE
Downward / unfavorable trend — uses the error color.
AfpSparklineTrend
Default AfpSparklineTrend.NEUTRAL
curve
Interpolation method used to connect data points.
Type
AfpSparklineCurve
Name Description
LINEAR
Straight lines between each consecutive data point.
NATURAL
Smooth curve using a Catmull-Rom → cubic Bézier conversion.
STEP
Horizontal then vertical segments — a staircase effect.
AfpSparklineCurve
Default AfpSparklineCurve.LINEAR

CSS Parts

Learn more about CSS Parts.

Name Description Selector
base
The SVG root element.
::part(base)
line
The stroke path.
::part(line)
fill
The filled area path (solid and gradient appearances).
::part(fill)

CSS Custom Properties

Name Description Default
--afp-sparkline-line-color
Stroke color of the line.
currentColor
--afp-sparkline-fill-color
Fill color of the area beneath the line.
currentColor
--afp-sparkline-line-width
Stroke width of the line.
1.5
--afp-sparkline-color-neutral
Color applied when `trend` is `neutral`.
--afp-color-brand-500
--afp-sparkline-color-positive
Color applied when `trend` is `positive`.
--afp-color-success-fill-loud
--afp-sparkline-color-negative
Color applied when `trend` is `negative`.
--afp-color-error-fill-loud

Importing

Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.

import '@afp-design-system/core/dist/components/sparkline/sparkline.js';
esc
Share
Create a link with a predefined theme that is automatically applied when the generated link is opened. Default LBBW Presentation Mode
Abort Copy Link