Epicenter
Local-first, open source apps
| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
Installation
Install bits-ui and @internationalized/date:
Copy and paste the following code into your project.
Usage
<script lang="ts">
import { getLocalTimeZone, today } from "@internationalized/date";
import { Calendar } from "$lib/components/ui/calendar/index.js";
let value = $state(today(getLocalTimeZone()));
</script> <Calendar type="single" bind:value class="rounded-lg border" /> See the Bits UI Calendar documentation for more information.
About
The <Calendar /> component is built on top of the Bits UI Calendar component, which uses the @internationalized/date package to handle dates.
Date Picker
You can use the <Calendar /> component to build a date picker. See the Date Picker page for more information.
Basic
A basic calendar component. We used class="rounded-lg border" to style the calendar.
| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
Range Calendar
Use the RangeCalendar component to enable range selection.
Month and Year Selector
Use captionLayout="dropdown" to show month and year dropdowns.
| Su | Mo | Tu | We | Th | Fr | Sa |
|---|---|---|---|---|---|---|
Presets
Date and Time Picker
Booked dates
Custom Cell Size
You can customize the size of calendar cells using the --cell-size CSS variable. You can also make it responsive by using breakpoint-specific values:
<Calendar
type="single"
bind:value
class="rounded-lg border [--cell-size:--spacing(11)] md:[--cell-size:--spacing(12)]"
/> Or use fixed values:
<Calendar
type="single"
bind:value
class="rounded-lg border [--cell-size:2.75rem] md:[--cell-size:3rem]"
/>