Skip to content

feat(datepicker): add showOutsideDays prop and css fixes#1671

Open
Karan5656 wants to merge 4 commits intothemesberg:mainfrom
Karan5656:feat/datepicker-out-of-month-days
Open

feat(datepicker): add showOutsideDays prop and css fixes#1671
Karan5656 wants to merge 4 commits intothemesberg:mainfrom
Karan5656:feat/datepicker-out-of-month-days

Conversation

@Karan5656
Copy link
Copy Markdown

@Karan5656 Karan5656 commented Apr 14, 2026

Changes

  • Added showOutsideDays prop to control visibility of out-of-month days.
  • Updated styles for out-of-month and disabled days.
  • Handled view change when out-of-month days are clicked.

Fixes

Fixes #1647

Summary by CodeRabbit

  • New Features

    • Added a showOutsideDays option to Datepicker to toggle display of adjacent-month days.
    • Calendar view now auto-synchronizes to the selected date so the displayed month matches your choice.
  • Styling

    • Improved appearance and behavior for outside, hidden, and disabled day states for clearer visual cues.
  • Documentation

    • Added docs, interactive example, and updated Storybook stories demonstrating showOutsideDays.
  • Chores

    • Added a release changeset for the datepicker update.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

@Karan5656 is attempting to deploy a commit to the Bergside Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 14, 2026

🦋 Changeset detected

Latest commit: feb3544

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c155ae18-29d8-43cd-8278-e8fa72eb4897

📥 Commits

Reviewing files that changed from the base of the PR and between 22413a6 and feb3544.

📒 Files selected for processing (1)
  • .changeset/flat-spoons-double.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/flat-spoons-double.md

📝 Walkthrough

Walkthrough

Added a new Datepicker prop showOutsideDays (default true), propagated through context to Views/Days; Days now detects outside-month days and can hide or style them. Selection now syncs viewDate with selected date. Storybook, docs, and examples updated to demonstrate the feature.

Changes

Cohort / File(s) Summary
Storybook Stories
apps/storybook/src/Datepicker.stories.tsx
Added showOutsideDays: true to multiple story .args for consistent rendering.
Docs & Examples
apps/web/content/docs/components/datepicker.mdx, apps/web/examples/datepicker/datepicker.showOutsideDays.tsx, apps/web/examples/datepicker/index.ts
Added "Outside days" docs section, new example datepicker.showOutsideDays.tsx demonstrating showOutsideDays={false}, and re-exported the example.
Datepicker Component
packages/ui/src/components/Datepicker/Datepicker.tsx
Added prop showOutsideDays?: boolean (default true) and passed it into context; changeSelectedDate() now calls setViewDate(date) when a date is selected.
Context & Views
packages/ui/src/components/Datepicker/DatepickerContext.tsx, packages/ui/src/components/Datepicker/Views/Days.tsx, packages/ui/src/components/Datepicker/theme.ts
Extended context with showOutsideDays; Days uses isMonthEqual to detect outside-month days, computes isHidden = outside && !showOutsideDays, prevents clicks on hidden days, adjusts disabled logic, and adds outside/hidden theme keys; theme strings updated for disabled/outside/hidden states.
Changeset
.changeset/flat-spoons-double.md
New changeset declaring the feature release for datepicker and related CSS fixes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Datepicker as Datepicker(Component)
    participant Context as DatepickerContext
    participant DaysView as Days(Views/Days)

    User->>Datepicker: click day (date)
    Datepicker->>Context: changeSelectedDate(date)
    Context->>Context: setSelectedDate(date)\nsetViewDate(date)
    Context->>DaysView: provide showOutsideDays, viewDate, selectedDate
    DaysView->>DaysView: compute isOutsideDay via isMonthEqual\ndetermine isHidden = isOutsideDay && !showOutsideDays
    DaysView-->>User: render day cells (apply outside/hidden styles, block clicks if hidden)
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly Related PRs

  • #1627: Modifies Datepicker day rendering and theme keys; touches similar theme and day-rendering logic.
  • #1457: Adds or uses isMonthEqual utilities for month-level comparisons used in Days view.
  • #1587: Alters Datepicker day-rendering/disable logic and prop propagation; overlaps with showOutsideDays behavior.

Suggested Reviewers

  • rluders
  • SutuSebastian
  • robert1508

Poem

🐰 I hopped through code to dim some days,
Outside-month numbers now fade their rays.
A prop, a theme, a gentler sight—
Calendars breathe in softer light.
Hop, hop, hooray — the months feel right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(datepicker): add showOutsideDays prop and css fixes' accurately summarizes the main changes: adding a new prop to control out-of-month day visibility and updating related CSS styling.
Linked Issues check ✅ Passed The PR fully addresses issue #1647 requirements: adds showOutsideDays prop to control visibility, implements visual de-emphasis of out-of-month days, provides theme tokens (outside/hidden), keeps days interactive, and ensures selected styling overrides.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the showOutsideDays feature and its styling requirements; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/ui/src/components/Datepicker/Datepicker.tsx (1)

161-164: Small cleanup: avoid duplicate viewDate updates.

After Line 163, changeSelectedDate(today, true) already syncs viewDate, so the extra setViewDate(today) in the Today button handler is redundant.

♻️ Suggested simplification
                      onClick={() => {
                        const today = new Date();
                        changeSelectedDate(today, true);
-                        setViewDate(today);
                      }}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ui/src/components/Datepicker/Datepicker.tsx` around lines 161 - 164,
The Today button handler is redundantly calling setViewDate(today) even though
changeSelectedDate(today, true) already updates viewDate; remove the extra
setViewDate(today) from the Today button's onClick handler (or equivalent) so
that only changeSelectedDate handles syncing viewDate, keeping the
changeSelectedDate(date: Date | null, useAutohide: boolean) function as the
single source of truth for updating viewDate.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/ui/src/components/Datepicker/theme.ts`:
- Around line 51-53: The disabled/outside/hidden state class strings in the
Datepicker theme object still inherit the base "dark:text-white" and stay too
bright in dark mode; update the object entries for the keys disabled, outside,
and hidden to include explicit dark-mode de-emphasis (e.g., add a
"dark:text-gray-500" or similar muted dark token) so those states override the
base dark:text-white — modify the strings for disabled, outside, and hidden in
the theme.ts Datepicker theme object accordingly.

---

Nitpick comments:
In `@packages/ui/src/components/Datepicker/Datepicker.tsx`:
- Around line 161-164: The Today button handler is redundantly calling
setViewDate(today) even though changeSelectedDate(today, true) already updates
viewDate; remove the extra setViewDate(today) from the Today button's onClick
handler (or equivalent) so that only changeSelectedDate handles syncing
viewDate, keeping the changeSelectedDate(date: Date | null, useAutohide:
boolean) function as the single source of truth for updating viewDate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1aaecba9-e1da-4d99-8264-5c8083c4fde9

📥 Commits

Reviewing files that changed from the base of the PR and between 0f526aa and 833d25c.

📒 Files selected for processing (8)
  • apps/storybook/src/Datepicker.stories.tsx
  • apps/web/content/docs/components/datepicker.mdx
  • apps/web/examples/datepicker/datepicker.showOutsideDays.tsx
  • apps/web/examples/datepicker/index.ts
  • packages/ui/src/components/Datepicker/Datepicker.tsx
  • packages/ui/src/components/Datepicker/DatepickerContext.tsx
  • packages/ui/src/components/Datepicker/Views/Days.tsx
  • packages/ui/src/components/Datepicker/theme.ts

Comment on lines +51 to +53
disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:hover:bg-transparent",
outside: "text-gray-300",
hidden: "cursor-default opacity-0 hover:bg-transparent dark:hover:bg-transparent",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Dark mode de-emphasis is currently overridden for disabled/outside days.

Because the base class has dark:text-white (Line 49), disabled/outside states stay too bright in dark mode. Add explicit dark:text-* overrides for those states.

🎨 Suggested fix
-          disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:hover:bg-transparent",
-          outside: "text-gray-300",
+          disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:text-gray-500 dark:hover:bg-transparent",
+          outside: "text-gray-300 dark:text-gray-500",
           hidden: "cursor-default opacity-0 hover:bg-transparent dark:hover:bg-transparent",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:hover:bg-transparent",
outside: "text-gray-300",
hidden: "cursor-default opacity-0 hover:bg-transparent dark:hover:bg-transparent",
disabled: "cursor-not-allowed text-gray-300 hover:bg-transparent dark:text-gray-500 dark:hover:bg-transparent",
outside: "text-gray-300 dark:text-gray-500",
hidden: "cursor-default opacity-0 hover:bg-transparent dark:hover:bg-transparent",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ui/src/components/Datepicker/theme.ts` around lines 51 - 53, The
disabled/outside/hidden state class strings in the Datepicker theme object still
inherit the base "dark:text-white" and stay too bright in dark mode; update the
object entries for the keys disabled, outside, and hidden to include explicit
dark-mode de-emphasis (e.g., add a "dark:text-gray-500" or similar muted dark
token) so those states override the base dark:text-white — modify the strings
for disabled, outside, and hidden in the theme.ts Datepicker theme object
accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support out-of-month days style

1 participant