Zubra UI
Code for
GitHub

streak-grid

A habit's last weeks as a grid of days (a column per week, Monday at the top), shaded by how much of the goal was done. Choosing a day toggles it; arrow keys move between days. log maps "YYYY-MM-DD" to a count; today is "YYYY-MM-DD".

Try it: events appear here (daytoggle).

Source: streak-grid.zb, and its registry item.

Install

Compiled (any project)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/streak-grid.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/streak-grid.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/streak-grid.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/streak-grid.json
One file, no dependencies (3.7 KB gzipped)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/streak-grid.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/streak-grid.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/streak-grid.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/streak-grid.json
.zb source (to edit it with Zubra)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/streak-grid.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/streak-grid.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/streak-grid.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/streak-grid.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/streak-grid.js"></script>

The compiled install writes src/components/zubra/streak-grid.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
<streak-grid label="Reading streak" today="2026-11-08"></streak-grid>

<script type="module">
  import './components/zubra/streak-grid.js';

  const element = document.querySelector('streak-grid');
  element.goal = 2;
  element.weeks = 8;
  element.log = {
    "2026-11-07": 1,
    "2026-11-06": 2,
    "2026-11-05": 2,
    "2026-11-04": 1,
    "2026-11-02": 2,
    "2026-10-31": 1,
    "2026-10-30": 2,
    "2026-10-29": 2,
    "2026-10-28": 1,
    "2026-10-26": 2,
    "2026-10-24": 1,
    "2026-10-23": 2,
    "2026-10-22": 2,
    "2026-10-21": 1,
    "2026-10-19": 2,
    "2026-10-17": 1,
    "2026-10-16": 2,
    "2026-10-15": 2,
    "2026-10-14": 1,
    "2026-10-12": 2,
    "2026-10-10": 1,
    "2026-10-09": 2,
    "2026-10-08": 2,
    "2026-10-07": 1,
    "2026-10-05": 2,
    "2026-10-03": 1,
    "2026-10-02": 2,
    "2026-10-01": 2,
    "2026-09-30": 1,
    "2026-09-28": 2,
    "2026-09-26": 1,
    "2026-09-25": 2,
    "2026-09-24": 2,
    "2026-09-23": 1,
    "2026-09-21": 2,
    "2026-09-19": 1,
    "2026-09-18": 2,
    "2026-09-17": 2,
    "2026-09-16": 1,
    "2026-09-14": 2,
  };
  element.addEventListener('daytoggle', (event) => console.log('daytoggle', event.detail));
</script>
Example.jsx
import './components/zubra/streak-grid.js';

const goal = 2;
const weeks = 8;
const log = {
  "2026-11-07": 1,
  "2026-11-06": 2,
  "2026-11-05": 2,
  "2026-11-04": 1,
  "2026-11-02": 2,
  "2026-10-31": 1,
  "2026-10-30": 2,
  "2026-10-29": 2,
  "2026-10-28": 1,
  "2026-10-26": 2,
  "2026-10-24": 1,
  "2026-10-23": 2,
  "2026-10-22": 2,
  "2026-10-21": 1,
  "2026-10-19": 2,
  "2026-10-17": 1,
  "2026-10-16": 2,
  "2026-10-15": 2,
  "2026-10-14": 1,
  "2026-10-12": 2,
  "2026-10-10": 1,
  "2026-10-09": 2,
  "2026-10-08": 2,
  "2026-10-07": 1,
  "2026-10-05": 2,
  "2026-10-03": 1,
  "2026-10-02": 2,
  "2026-10-01": 2,
  "2026-09-30": 1,
  "2026-09-28": 2,
  "2026-09-26": 1,
  "2026-09-25": 2,
  "2026-09-24": 2,
  "2026-09-23": 1,
  "2026-09-21": 2,
  "2026-09-19": 1,
  "2026-09-18": 2,
  "2026-09-17": 2,
  "2026-09-16": 1,
  "2026-09-14": 2,
};

export function StreakGridExample() {
  return (
    <streak-grid
      label="Reading streak"
      today="2026-11-08"
      goal={goal}
      weeks={weeks}
      log={log}
      ondaytoggle={(event) => console.log('daytoggle', event.detail)}
    ></streak-grid>
  );
}
Example.vue
<script setup>
import './components/zubra/streak-grid.js';
const goal = 2;
const weeks = 8;
const log = {
  "2026-11-07": 1,
  "2026-11-06": 2,
  "2026-11-05": 2,
  "2026-11-04": 1,
  "2026-11-02": 2,
  "2026-10-31": 1,
  "2026-10-30": 2,
  "2026-10-29": 2,
  "2026-10-28": 1,
  "2026-10-26": 2,
  "2026-10-24": 1,
  "2026-10-23": 2,
  "2026-10-22": 2,
  "2026-10-21": 1,
  "2026-10-19": 2,
  "2026-10-17": 1,
  "2026-10-16": 2,
  "2026-10-15": 2,
  "2026-10-14": 1,
  "2026-10-12": 2,
  "2026-10-10": 1,
  "2026-10-09": 2,
  "2026-10-08": 2,
  "2026-10-07": 1,
  "2026-10-05": 2,
  "2026-10-03": 1,
  "2026-10-02": 2,
  "2026-10-01": 2,
  "2026-09-30": 1,
  "2026-09-28": 2,
  "2026-09-26": 1,
  "2026-09-25": 2,
  "2026-09-24": 2,
  "2026-09-23": 1,
  "2026-09-21": 2,
  "2026-09-19": 1,
  "2026-09-18": 2,
  "2026-09-17": 2,
  "2026-09-16": 1,
  "2026-09-14": 2,
};
const onDaytoggle = (event) => console.log('daytoggle', event.detail);
</script>

<template>
  <streak-grid
    label="Reading streak"
    today="2026-11-08"
    :goal.prop="goal"
    :weeks.prop="weeks"
    :log.prop="log"
    @daytoggle="onDaytoggle"
  ></streak-grid>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/streak-grid.js';
  const goal = 2;
  const weeks = 8;
  const log = {
    "2026-11-07": 1,
    "2026-11-06": 2,
    "2026-11-05": 2,
    "2026-11-04": 1,
    "2026-11-02": 2,
    "2026-10-31": 1,
    "2026-10-30": 2,
    "2026-10-29": 2,
    "2026-10-28": 1,
    "2026-10-26": 2,
    "2026-10-24": 1,
    "2026-10-23": 2,
    "2026-10-22": 2,
    "2026-10-21": 1,
    "2026-10-19": 2,
    "2026-10-17": 1,
    "2026-10-16": 2,
    "2026-10-15": 2,
    "2026-10-14": 1,
    "2026-10-12": 2,
    "2026-10-10": 1,
    "2026-10-09": 2,
    "2026-10-08": 2,
    "2026-10-07": 1,
    "2026-10-05": 2,
    "2026-10-03": 1,
    "2026-10-02": 2,
    "2026-10-01": 2,
    "2026-09-30": 1,
    "2026-09-28": 2,
    "2026-09-26": 1,
    "2026-09-25": 2,
    "2026-09-24": 2,
    "2026-09-23": 1,
    "2026-09-21": 2,
    "2026-09-19": 1,
    "2026-09-18": 2,
    "2026-09-17": 2,
    "2026-09-16": 1,
    "2026-09-14": 2,
  };
</script>

<streak-grid
  label="Reading streak"
  today="2026-11-08"
  {goal}
  {weeks}
  {log}
  ondaytoggle={(event) => console.log('daytoggle', event.detail)}
></streak-grid>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/streak-grid.js';

@Component({
  selector: 'app-streak-grid-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <streak-grid
      label="Reading streak"
      today="2026-11-08"
      [goal]="goal"
      [weeks]="weeks"
      [log]="log"
      (daytoggle)="onDaytoggle($event)"
    ></streak-grid>
  `,
})
export class StreakGridExample {
  goal = 2;

  weeks = 8;

  log = {
    "2026-11-07": 1,
    "2026-11-06": 2,
    "2026-11-05": 2,
    "2026-11-04": 1,
    "2026-11-02": 2,
    "2026-10-31": 1,
    "2026-10-30": 2,
    "2026-10-29": 2,
    "2026-10-28": 1,
    "2026-10-26": 2,
    "2026-10-24": 1,
    "2026-10-23": 2,
    "2026-10-22": 2,
    "2026-10-21": 1,
    "2026-10-19": 2,
    "2026-10-17": 1,
    "2026-10-16": 2,
    "2026-10-15": 2,
    "2026-10-14": 1,
    "2026-10-12": 2,
    "2026-10-10": 1,
    "2026-10-09": 2,
    "2026-10-08": 2,
    "2026-10-07": 1,
    "2026-10-05": 2,
    "2026-10-03": 1,
    "2026-10-02": 2,
    "2026-10-01": 2,
    "2026-09-30": 1,
    "2026-09-28": 2,
    "2026-09-26": 1,
    "2026-09-25": 2,
    "2026-09-24": 2,
    "2026-09-23": 1,
    "2026-09-21": 2,
    "2026-09-19": 1,
    "2026-09-18": 2,
    "2026-09-17": 2,
    "2026-09-16": 1,
    "2026-09-14": 2,
  };

  onDaytoggle(event: Event) {
    console.log('daytoggle', (event as CustomEvent).detail);
  }
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
log
property only
{ 2026-11-07, 2026-11-06, 2026-11-05, 2026-11-04, 2026-11-02, 2026-10-31, 2026-10-30, 2026-10-29, 2026-10-28, 2026-10-26, 2026-10-24, 2026-10-23, 2026-10-22, 2026-10-21, 2026-10-19, 2026-10-17, 2026-10-16, 2026-10-15, 2026-10-14, 2026-10-12, 2026-10-10, 2026-10-09, 2026-10-08, 2026-10-07, 2026-10-05, 2026-10-03, 2026-10-02, 2026-10-01, 2026-09-30, 2026-09-28, 2026-09-26, 2026-09-25, 2026-09-24, 2026-09-23, 2026-09-21, 2026-09-19, 2026-09-18, 2026-09-17, 2026-09-16, 2026-09-14 }{}
goalnumber1
todaystring""
weeksnumber12
labelstring"History"
Events
EventWhen
daytoggleA day was chosen; detail is the day.

Size

1.6 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 18.1 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