@molecule/app-habit-streak-card-vue
Feature · habit-streak-card · App (browser) · v1.1.2 · Apache-2.0
Habit / streak card with current streak, best streak, completion heatmap
npm install @molecule/app-habit-streak-card-vueHow it works
@molecule/app-habit-streak-card-vue is a ready-made habit-streak-card feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { defineComponent, h } from 'vue'
import type { StreakDay } from '@molecule/app-habit-streak-card-vue'
import { HabitStreakCard } from '@molecule/app-habit-streak-card-vue'
const recentDays: StreakDay[] = [
{ date: '2026-07-01', count: 1 },
{ date: '2026-07-02', count: 3 },
]
const HabitView = defineComponent({
setup() {
return () =>
h(HabitStreakCard, {
name: 'Morning Run',
icon: h('span', '🏃'),
currentStreak: 14,
bestStreak: 30,
totalCompletions: 87,
heatmap: recentDays,
})
},
})Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue habit / streak summary card — current streak, best streak, total completions, and an optional per-day heatmap strip. Use for habit trackers, meditation streaks, daily-task widgets.
Exports <HabitStreakCard> and the StreakDay / HabitStreakCardProps
types.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { defineComponent, h } from 'vue'
import type { StreakDay } from '@molecule/app-habit-streak-card-vue'
import { HabitStreakCard } from '@molecule/app-habit-streak-card-vue'
const recentDays: StreakDay[] = [
{ date: '2026-07-01', count: 1 },
{ date: '2026-07-02', count: 3 },
]
const HabitView = defineComponent({
setup() {
return () =>
h(HabitStreakCard, {
name: 'Morning Run',
icon: h('span', '🏃'),
currentStreak: 14,
bestStreak: 30,
totalCompletions: 87,
heatmap: recentDays,
})
},
})
Type
feature
Installation
npm install @molecule/app-habit-streak-card-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
API
Interfaces
StreakDay
Represents a single day's completion data for the heatmap strip.
interface StreakDay {
/** ISO date (yyyy-mm-dd). */
date: string
/** Completion count for the day (0 = not done, >0 = intensity). */
count: number
}
HabitStreakCardProps
Props accepted by the HabitStreakCard component (React's names).
interface HabitStreakCardProps {
/** Habit name. Passed as a prop or as the same-named slot — both work. */
name: VNodeChild
/** Optional leading icon. Passed as a prop or as the same-named slot. */
icon?: VNodeChild
/** Current streak (days). */
currentStreak: number
/** Best streak (days). */
bestStreak?: number
/** Total completions. */
totalCompletions?: number
/** Optional heatmap days — rendered as a strip of squares. */
heatmap?: StreakDay[]
/** Days the heatmap should display (truncates `heatmap` from the end). Defaults to 30. */
heatmapDays?: number
/** Extra classes. */
className?: string
}
Constants
HabitStreakCard
Habit / streak summary card with current + best streak, total completions, and an optional heatmap strip.
Vue counterpart of @molecule/app-habit-streak-card-react's
HabitStreakCard — the same props (React names), the same ClassMap tokens
and the same DOM for the same input. The stat labels and the heatmap's
strip and day labels go through useTranslation() with React's exact keys
and English defaults, and heatmapDays truncates heatmap from the end
(most recent days win).
const HabitStreakCard: DefineComponent<
ExtractPropTypes<{
name: { type: null; required: true }
icon: { type: null }
currentStreak: { type: NumberConstructor; required: true }
bestStreak: { type: NumberConstructor }
totalCompletions: { type: NumberConstructor }
heatmap: { type: PropType<StreakDay[]> }
heatmapDays: { type: NumberConstructor; default: number }
className: StringConstructor
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
name: { type: null; required: true }
icon: { type: null }
currentStreak: { type: NumberConstructor; required: true }
bestStreak: { type: NumberConstructor }
totalCompletions: { type: NumberConstructor }
heatmap: { type: PropType<StreakDay[]> }
heatmapDays: { type: NumberConstructor; default: number }
className: StringConstructor
}>
> &
Readonly<{}>,
{ heatmapDays: number },
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeHabitStreakCardPropsin./types.js).
Returns: The habit streak card component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.5.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
-
@molecule/app-ui -
@molecule/app-ui-vue -
@molecule/app-vue -
vue -
Requires the Vue binding's i18n provider (
useTranslation()THROWS without it) and a bonded ClassMap forgetClassMap(). Stat labels come from the@molecule/app-locales-habit-streak-cardcompanion bond. -
The heatmap strip uses a fixed green ramp with a light-only zero color (
rgba(0,0,0,0.08)) rendered as inline styles — on dark themes the empty cells are nearly invisible. For a theme-aware year grid use@molecule/app-heatmap-vuewith a customcolorScaleinstead. -
heatmapDaystruncatesheatmapfrom the END (most recent days win). -
The
nameandiconprops are node-valued: each may be passed as a prop or as the same-named Vue slot.
Translations
Translation strings are provided by @molecule/app-locales-habit-streak-card.