mirror of
https://github.com/supabase/supabase.git
synced 2026-10-06 18:05:11 +03:00
## What Fixes misaligned day cells in the PITR calendar widget for the first week of the month. ## Why The PITR calendar draws a \`border\` on each day cell via \`classNames.day\`. The day \`<td>\` has no explicit width, so \`box-sizing: border-box\` doesn't apply and the 1px borders add to its size (36px → 38px), while the weekday header cells stay pinned at \`w-9\` (36px). Bordered day cells therefore drift right of their headers, which is most visible in the first partial week where unbordered leading cells sit flush next to the wider bordered ones. ## How Pin each day cell to a fixed \`w-9 box-border\` so the border is drawn inside the 36px box, and let the day button fill the cell (\`w-full\`). Column pitch now matches the weekday headers regardless of border state. Class-only change, no logic touched. Closes FE-3886 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Style** * Improved calendar day cell sizing and layout for more consistent rendering. * Ensured day buttons use full-width styling where applicable, while preserving existing hover, border, background, and corner behavior. * **Documentation** * Added documentation for “Calendar with disabled days,” including a new interactive preview. * **New Features** * Introduced a calendar example demonstrating disabled-day behavior with mid-week month start and restricted date selection. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
88 lines
1.8 KiB
Plaintext
88 lines
1.8 KiB
Plaintext
---
|
|
title: Calendar
|
|
description: A date field component that allows users to enter and edit date.
|
|
component: true
|
|
links:
|
|
doc: https://react-day-picker.js.org
|
|
source:
|
|
shadcn: true
|
|
---
|
|
|
|
<ComponentPreview name="calendar-demo" peekCode wide />
|
|
|
|
## About
|
|
|
|
The `Calendar` component is built on top of [React DayPicker](https://react-day-picker.js.org).
|
|
|
|
## Installation
|
|
|
|
<Tabs defaultValue="cli">
|
|
|
|
<TabsList>
|
|
<TabsTrigger value="cli">CLI</TabsTrigger>
|
|
<TabsTrigger value="manual">Manual</TabsTrigger>
|
|
</TabsList>
|
|
<TabsContent value="cli">
|
|
|
|
```bash
|
|
npx shadcn-ui@latest add calendar
|
|
```
|
|
|
|
</TabsContent>
|
|
|
|
<TabsContent value="manual">
|
|
|
|
<Steps>
|
|
|
|
<Step>Install the following dependencies:</Step>
|
|
|
|
```bash
|
|
npm install react-day-picker date-fns
|
|
```
|
|
|
|
<Step>Add the `Button` component to your project.</Step>
|
|
|
|
The `Calendar` component uses the `Button` component. Make sure you have it installed in your project.
|
|
|
|
<Step>Copy and paste the following code into your project.</Step>
|
|
|
|
<ComponentSource name="calendar" />
|
|
|
|
<Step>Update the import paths to match your project setup.</Step>
|
|
|
|
</Steps>
|
|
|
|
</TabsContent>
|
|
|
|
</Tabs>
|
|
|
|
## Usage
|
|
|
|
```tsx
|
|
import { Calendar } from '@/components/ui/calendar'
|
|
```
|
|
|
|
```tsx
|
|
const [date, setDate] = React.useState<Date | undefined>(new Date())
|
|
|
|
return <Calendar mode="single" selected={date} onSelect={setDate} className="rounded-md border" />
|
|
```
|
|
|
|
See the [React DayPicker](https://react-day-picker.js.org) documentation for more information.
|
|
|
|
## Date Picker
|
|
|
|
You can use the `<Calendar>` component to build a date picker. See the [Date Picker](/docs/components/date-picker) page for more information.
|
|
|
|
## Examples
|
|
|
|
### Form
|
|
|
|
<ComponentPreview name="calendar-form" />
|
|
|
|
### Calendar with disabled days
|
|
|
|
Shows a calendar with disabled days for selection. The current month starts mid week.
|
|
|
|
<ComponentPreview name="calendar-disabled-days-demo" />
|