CalendarHeatmap

GitHub-style contribution calendar with interactive features

Database Connected
1,182
Total Contributions
289
Active Days
4.1
Average Per Day
11
Best Day

Key Features

πŸ“…

Calendar Grid

52 weeks Γ— 7 days grid with Sunday-Saturday layout, matching GitHub's design

🎨

Color Levels

5 discrete intensity levels with customizable color schemes

πŸ’¬

Tooltips

Hover tooltips showing date and contribution count

⌨️

Keyboard Nav

Arrow key navigation with Enter/Space for selection

πŸ“±

Responsive

SVG-based rendering scales perfectly on all screen sizes

β™Ώ

Accessible

Full ARIA labels, keyboard support, and screen reader compatibility

Basic Calendar

Default GitHub-style calendar showing past 365 days of activity. Hover over cells to see details, click to select.

JanFebMarAprMayJunJulAugSepOctNovDecJanMonWedFri
Less
More
<script>
  import CalendarHeatmap from '$lib/components/CalendarHeatmap.svelte';

  let activityData = [
    { date: '2024-01-15', value: 12 },
    { date: '2024-01-16', value: 8 },
    // ... more data
  ];
</script>

<CalendarHeatmap
  data={activityData}
  onCellClick={(date, value) => console.log(date, value)}
/>

Color Schemes

Customize the color palette to match your application's theme. Choose from preset schemes or define your own.

JanFebMarAprMayJunJulAugSepOctNovDecJanMonWedFri
Less
More
<CalendarHeatmap
  data={activityData}
  colorLow="#f0f9ff"
  colorHigh="#0369a1"
/>

Compact Version

Smaller cells without labels for embedding in tight spaces. Perfect for dashboards and summary views.

<CalendarHeatmap
  data={activityData}
  cellSize={8}
  cellGap={2}
  showWeekLabels={false}
  showMonthLabels={false}
  showLegend={false}
/>

Custom Date Range

Display a specific date range instead of the default 365 days. Use the filter to select different time periods.

OctNovDecJanMonWedFri
Less
More
<script>
  const daysAgo = 90;
  const startDate = new Date();
  startDate.setDate(startDate.getDate() - daysAgo);
</script>

<CalendarHeatmap
  data={activityData}
  startDate={startDate}
  endDate={new Date()}
/>

Props Reference

PropTypeDefaultDescription
dataCalendarDataPoint[]requiredArray of { date: string, value: number } objects
startDateDate365 days agoFirst date to display in calendar
endDateDatetodayLast date to display in calendar
colorLowstring'#ebedf0'Colour for lowest activity (level 0)
colorHighstring'#216e39'Colour for highest activity (level 4)
cellSizenumber12Size of each calendar cell in pixels
cellGapnumber3Gap between cells in pixels
showWeekLabelsbooleantrueShow weekday labels (Mon/Wed/Fri)
showMonthLabelsbooleantrueShow month labels at top
showLegendbooleantrueShow colour legend below calendar
levelsnumber5Number of discrete colour levels
tooltipFormatterfunction-Custom tooltip formatter: (date, value) => string
onCellClickfunction-Click handler: (date, value) => void
classstring''Additional CSS classes

Use Cases

🎯 Habit Tracking

Visualize daily habits like exercise, meditation, or reading streaks

πŸ’» Developer Activity

Display GitHub-style contribution graphs for project dashboards

πŸ“Š Business Metrics

Track daily sales, user signups, or other key performance indicators

πŸƒ Fitness Logging

Monitor workout frequency and intensity over time

🌑️ Environmental Data

Visualize temperature, pollution levels, or weather patterns

⏰ Time Tracking

Display project hours, task completion, or productivity patterns

Implementation Details

Zero Dependencies

Built with pure Svelte 5 and native web technologies. No external charting libraries required.

Performance

O(1) data lookups using Map. Handles 365+ cells with smooth rendering and interactions.

Accessibility

Full keyboard navigation, ARIA labels, focus management, and screen reader support included.

Responsive

SVG viewBox scaling ensures perfect rendering on all screen sizes and devices.