Skip to content

Conversation

@bayashiko-r
Copy link

@bayashiko-r bayashiko-r commented Dec 15, 2025

Hi @shadcn,

This pull request updates the SidebarProvider logic to persist the sidebar's open/collapsed state across sessions by utilizing browser cookies.

Key Changes:

  • Initial State Read: The internal state (_open) now uses a lazy initializer function with React.useState to read the saved state from the SIDEBAR_COOKIE_NAME cookie on component mount.
  • Default Fallback: If the cookie is not present (first-time load), the state correctly falls back to the defaultOpen prop.
  • State Write: The setOpen callback is updated to correctly set the sidebar state in the cookie whenever the state changes.
  • Code Clarity: Updated internal comments to accurately reflect the uncontrolled state initialization logic (reading from the cookie).

closes Issue #8176

@vercel
Copy link
Contributor

vercel bot commented Dec 15, 2025

@bayashiko-r is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

@bayashiko-r bayashiko-r marked this pull request as ready for review December 15, 2025 16:23
@bayashiko-r bayashiko-r changed the title Fix: Persist sidebar state using cookies for initial load fix: Persist sidebar state using cookies for initial load Dec 15, 2025
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.

1 participant