← All Components
<mth-sparkline>
Accessible inline SVG sparkline (line, area, and bar) with <title>, <desc>, and screen-reader numeric summary fallback.
When NOT to use: Use a lightweight @methane-ui/css layout class instead of a custom element when static CSS suffices.
Live Interactive Preview
Ready · interact with <mth-sparkline>, or toggle Theme, Direction (LTR/RTL), or props above.
Multi-Framework Playground & Snippets
<script type="module" src="@methane-ui/ui/sparkline"></script>
<mth-sparkline type="line" variant="accent">Example</mth-sparkline>import '@methane-ui/ui/sparkline';
import '@methane-ui/react';
export function Example() {
return <mth-sparkline type="line" variant="accent">Example</mth-sparkline>;
}<script setup lang="ts">
import '@methane-ui/ui/sparkline';
</script>
<template>
<mth-sparkline type="line" variant="accent">Example</mth-sparkline>
</template>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@methane-ui/ui/sparkline';
import { MthSparklineDirective } from '@methane-ui/angular';
@Component({
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [MthSparklineDirective],
template: `<mth-sparkline type="line" variant="accent">Example</mth-sparkline>`,
})
export class ExampleComponent {}<script lang="ts">
import '@methane-ui/ui/sparkline';
import MthSparkline from '@methane-ui/svelte/MthSparkline.svelte';
</script>
<MthSparkline type="line" variant="accent">Example</MthSparkline>Properties & Attributes
| Property | Attribute | Type | Default | Description |
|---|---|---|---|---|
values | — | ReadonlyArray<number> | — | Numeric series array to plot. |
data | data | string | "" | Comma- or whitespace-separated numeric values for declarative HTML/SSR usage. |
type | type | 'line' | 'area' | 'bar' | "line" | Visualization mode (line, area, or bar). |
variant | variant | 'accent' | 'success' | 'warning' | 'danger' | 'neutral' | "accent" | Semantic stroke/fill palette (accent, success, warning, danger, neutral). |
label | label | string | "" | Accessible chart title used in SVG <title>. |
showPoints | show-points | boolean | false | Renders circular point markers on each data vertex. |
min | min | number | null | null | Optional explicit lower bound for Y-axis scaling. |
max | max | number | null | null | Optional explicit upper bound for Y-axis scaling. |
Accessibility Checklist
| Category | Requirement | Verified By |
|---|---|---|
| aria | All aria-* IDREFs resolve within the same DOM root (ADR-003). | scanSameRootAria |
| focus | Focus ownership matches focusModel="none". | lint-plugin & spec-compiler |
| contrast | Renders legible borders, focus outlines, and selection indicators under forced-colors: active. | Playwright forced-colors matrix |
| states | Exposes ElementInternals CustomStateSet flags: :state(empty). | Conformance suite |
| i18n | Routes 3 UI/ARIA strings through @methane-ui/core i18n catalog. | Locale context test |