Zubra UI
Code for
GitHub

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

Compiled (any project)
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
One file, no dependencies (1.7 KB gzipped)
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
.zb source (to edit it with Zubra)
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
No build: a script tag, straight from this site
HTML
<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

index.html
<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>
Example.jsx
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>
  );
}
Example.vue
<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('-') } } }) -->
Example.svelte
<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>
example.component.ts
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

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
points
property only
unknown[][]
labelstring"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.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour