spark-line
A small line of recent values, green when it ends higher than it started, red when lower.
This one has no events: it shows what it's given.
Source: spark-line.zb, and its registry item.
Install
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/spark-line.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/spark-line.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/spark-line.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/spark-line.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/spark-line.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/spark-line.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/spark-line.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/spark-line.json
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/spark-line.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/spark-line.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/spark-line.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/spark-line.json
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/spark-line.js"></script>The compiled install writes src/components/zubra/spark-line.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.
Usage
<spark-line label="Visitors this week"></spark-line>
<script type="module">
import './components/zubra/spark-line.js';
const element = document.querySelector('spark-line');
element.points = [120, 132, 101, 154, 190, 176, 210];
</script>import './components/zubra/spark-line.js';
const points = [120, 132, 101, 154, 190, 176, 210];
export function SparkLineExample() {
return (
<spark-line label="Visitors this week" points={points}></spark-line>
);
}<script setup>
import './components/zubra/spark-line.js';
const points = [120, 132, 101, 154, 190, 176, 210];
</script>
<template>
<spark-line label="Visitors this week" :points.prop="points"></spark-line>
</template>
<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) --><script>
import './components/zubra/spark-line.js';
const points = [120, 132, 101, 154, 190, 176, 210];
</script>
<spark-line label="Visitors this week" {points}></spark-line>import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/spark-line.js';
@Component({
selector: 'app-spark-line-example',
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<spark-line label="Visitors this week" [points]="points"></spark-line>
`,
})
export class SparkLineExample {
points = [120, 132, 101, 154, 190, 176, 210];
}API
| Property | Type | Default |
|---|---|---|
pointsproperty only | unknown[] | [] |
label | string | "Trend" |
Size
0.7 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 16.8 KB.