From 518b5ca5425ea765aff38a2776dc36739dcd2a3b Mon Sep 17 00:00:00 2001 From: Rohan Chakraborty Date: Tue, 29 Sep 2026 15:42:56 +0530 Subject: [PATCH 1/3] feat: [sidebar] add onPeekChange and peekBackdrop, fix inset peek background --- .../content/docs/components/sidebar/demo.ts | 10 ++++++++ .../content/docs/components/sidebar/index.mdx | 24 +++++++++++++++++++ .../content/docs/components/sidebar/props.ts | 8 +++++++ .../sidebar/__tests__/data-slots.test.tsx | 18 +++++++++++++- .../sidebar/__tests__/sidebar.test.tsx | 14 +++++++++++ .../components/sidebar/sidebar-root.tsx | 19 +++++++++++++++ .../components/sidebar/sidebar.module.css | 12 ++++++++++ 7 files changed, 104 insertions(+), 1 deletion(-) diff --git a/apps/www/src/content/docs/components/sidebar/demo.ts b/apps/www/src/content/docs/components/sidebar/demo.ts index 4a638a6b5..406097bcf 100644 --- a/apps/www/src/content/docs/components/sidebar/demo.ts +++ b/apps/www/src/content/docs/components/sidebar/demo.ts @@ -393,6 +393,16 @@ export const peekOnHoverDemo = { `) + }, + { + name: 'Backdrop', + code: sidebarLayout(` + + }>Overview + } active>Dashboard + }>Analytics + + `) } ], style: styleDemo diff --git a/apps/www/src/content/docs/components/sidebar/index.mdx b/apps/www/src/content/docs/components/sidebar/index.mdx index 2f5eea99b..abe9167bc 100644 --- a/apps/www/src/content/docs/components/sidebar/index.mdx +++ b/apps/www/src/content/docs/components/sidebar/index.mdx @@ -91,6 +91,24 @@ The sidebar expands and collapses, animating between the two. Collapsed keeps ic +### External control + +`Sidebar.Trigger` and `useSidebar` work only inside ``. To toggle the sidebar from elsewhere, for example a top bar, control it with `open` and `onOpenChange`: + +```tsx +const [open, setOpen] = useState(true); + + setOpen(!open)} +> + + +… +``` + ### Non-collapsible Set `collapsible="none"` to hide the resize handle and prevent the sidebar from being collapsed or expanded. @@ -114,6 +132,11 @@ so hover the thin strip at the edge instead, as the "Hidden" tab below shows. The peek waits 100ms so it does not fire when the mouse only passes over. Change that with `peekDelay`. +The overlay always has an opaque background, also with `variant="inset"`. +Set `peekBackdrop` to dim the page behind it, as the "Backdrop" tab shows. Style +the backdrop with the `sidebar-backdrop` slot. `onPeekChange` reports when a +peek starts or ends, for UI outside the sidebar. + ### Custom tooltip message @@ -216,6 +239,7 @@ Every rendered part carries a stable `data-slot` attribute for [styling and test |------|---------| | `sidebar` | The root `