Ballmac UI home

Habits 1: streaks and weekly goals

A habit tracker: each habit with its streak (kept alive until today ends), best streak, this week against its goal, the last seven days to tick, twelve weeks as a grid, a ring for today, and ticks that go back if they fail.

State

The normal view. Pick a state to see what the block shows while it loads, is empty or fails.

Open in v0 (opens in a new tab)

Installation

$ pnpm dlx shadcn@latest add @ballmac/habits-1

Usage

Example: habits-1-demo.tsx
"use client"

import { Habits1 } from "@/components/ballmac/blocks/habits-1/habits-1"

export default function Habits1Demo() {
  return <Habits1 onToggle={() => new Promise((r) => setTimeout(r, 400))} />
}

States

Pass state and the block does the rest: skeletons that match its layout, a clear empty message, an error you can retry, and announcements for screen readers.

  • Loading

    Skeleton cards under the real heading, announced as loading.

    state="loading"
  • No habits yet

    Says to pick one small thing to do most days; emptyState sets the copy and can add a button.

    state="empty" (or habits={[]})
  • Could not load

    An alert saying nothing was lost, with Try again (onRetry). A tick that fails to save goes back with its reason under the habit.

    state="error"

Quality scorecard

7/7

Every applicable check passes

Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.0, across 5 examples.

How we measure
  • Passed: Accessibility scan

    No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).

  • Passed: Small screens

    No sideways scrolling at 360, 390 or 1280 px wide.

  • Passed: Reduced motion

    Every endless animation stops when the visitor asks for less motion.

  • Not applicable: Right to left

    Not mirrored by design: The twelve-week history runs oldest to newest from left to right in every language, like a chart, and makes up most of the page's elements.

  • Passed: Clean console

    No console errors or React hydration errors while loading.

  • Passed: Keyboard

    47 tab stops, each showing a visible change when it takes focus. 3 documented keys.

  • Passed: Loading, empty and error

    Ships loading, empty, error states, each with an example.

  • Passed: Automated tests

    Covered by habits-1.test.tsx.

  • For information: Footprint

    4.9 KB of source (gzip) in 1 file. Installs lucide-react.

Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.

Dependencies

Use with AI

A habit tracker. <Habits1 habits={[{ id, name, target: 5, done: ['2026-10-18'], tone: 1..5 }]} today='2026-10-18' locale onToggle={(habitId, date, done) => Promise} onAdd={({ name, target }) => Promise} />. The streak is the run of days ending today, or yesterday while today is not done yet, so it only breaks when a day is missed. Best streak, this-week count (Monday to today) and the goal are worked out from done. Pass today yourself; the block never reads the clock. Reject onToggle and the day goes back with the message. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Habits 1: streaks and weekly goals (@ballmac/habits-1) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Wellness, learning and productivity apps with daily routines
  • A team ritual tracker

Not for

  • One-off to-dos (use tasks-1)
  • Long-term targets with numbers (use goals-1)

Registry JSON: https://ui.ballmac.com/r/habits-1.json

Free to use in personal and commercial projects.

Ballmac UI Pro

Need the whole screen, not one piece?

150 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.