Skip to content

Commit 1d1cb8b

Browse files
authored
RAC: update pageBehavior docs to separate examples (#4682)
1 parent 0c15221 commit 1d1cb8b

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

packages/react-aria-components/docs/Calendar.mdx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,30 @@ The error message element within a `Calendar` can be targeted with the `[slot=er
421421

422422
Multiple `CalendarGrid` elements can be rendered to show multiple months at once. The `visibleDuration` prop should be provided to the `Calendar` component to specify how many months are visible, and each `CalendarGrid` accepts an `offset` prop to specify its starting date relative to the first visible date.
423423

424+
```tsx example
425+
<Calendar aria-label="Appointment date" visibleDuration={{months: 2}}>
426+
<header>
427+
<Button slot="previous">◀</Button>
428+
<Heading />
429+
<Button slot="next">▶</Button>
430+
</header>
431+
<div style={{display: 'flex', gap: 30, overflow: 'auto'}}>
432+
<CalendarGrid>
433+
{date => <CalendarCell date={date} />}
434+
</CalendarGrid>
435+
<CalendarGrid offset={{months: 1}}>
436+
{date => <CalendarCell date={date} />}
437+
</CalendarGrid>
438+
</div>
439+
</Calendar>
440+
```
441+
442+
### Page behavior
443+
424444
The `pageBehavior` prop allows you to control how the calendar navigates between months. By default, the calendar will navigate by `visibleDuration`, but by setting `pageBehavior` to `single`, pagination will be by one month.
425445

426446
```tsx example
427-
<Calendar aria-label="Appointment date" visibleDuration={{months: 2}} pageBehavior="single">
447+
<Calendar aria-label="Appointment date" visibleDuration={{months: 3}} pageBehavior="single">
428448
<header>
429449
<Button slot="previous">◀</Button>
430450
<Heading />
@@ -437,6 +457,9 @@ The `pageBehavior` prop allows you to control how the calendar navigates between
437457
<CalendarGrid offset={{months: 1}}>
438458
{date => <CalendarCell date={date} />}
439459
</CalendarGrid>
460+
<CalendarGrid offset={{months: 2}}>
461+
{date => <CalendarCell date={date} />}
462+
</CalendarGrid>
440463
</div>
441464
</Calendar>
442465
```

packages/react-aria-components/docs/RangeCalendar.mdx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,30 @@ The error message element within a `RangeCalendar` can be targeted with the `[sl
443443

444444
Multiple `CalendarGrid` elements can be rendered to show multiple months at once. The `visibleDuration` prop should be provided to the `RangeCalendar` component to specify how many months are visible, and each `CalendarGrid` accepts an `offset` prop to specify its starting date relative to the first visible date.
445445

446+
```tsx example
447+
<RangeCalendar aria-label="Trip dates" visibleDuration={{months: 2}}>
448+
<header>
449+
<Button slot="previous">◀</Button>
450+
<Heading />
451+
<Button slot="next">▶</Button>
452+
</header>
453+
<div style={{display: 'flex', gap: 30, overflow: 'auto'}}>
454+
<CalendarGrid>
455+
{date => <CalendarCell date={date} />}
456+
</CalendarGrid>
457+
<CalendarGrid offset={{months: 1}}>
458+
{date => <CalendarCell date={date} />}
459+
</CalendarGrid>
460+
</div>
461+
</RangeCalendar>
462+
```
463+
464+
### Page behavior
465+
446466
The `pageBehavior` prop allows you to control how the calendar navigates between months. By default, the calendar will navigate by `visibleDuration`, but by setting `pageBehavior` to `single`, pagination will be by one month.
447467

448468
```tsx example
449-
<RangeCalendar aria-label="Trip dates" visibleDuration={{months: 2}} pageBehavior="single">
469+
<RangeCalendar aria-label="Trip dates" visibleDuration={{months: 3}} pageBehavior="single">
450470
<header>
451471
<Button slot="previous">◀</Button>
452472
<Heading />
@@ -459,6 +479,9 @@ The `pageBehavior` prop allows you to control how the calendar navigates between
459479
<CalendarGrid offset={{months: 1}}>
460480
{date => <CalendarCell date={date} />}
461481
</CalendarGrid>
482+
<CalendarGrid offset={{months: 2}}>
483+
{date => <CalendarCell date={date} />}
484+
</CalendarGrid>
462485
</div>
463486
</RangeCalendar>
464487
```

0 commit comments

Comments
 (0)