How to programmatically open and close Sheet? #727
Replies: 3 comments 2 replies
-
I need this too. I'd like to close the sheet when the user click any link in the sheet, or when the page changes to a new route. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Eureka! I found the solution, the mobile-nav component. Create a variable called open and bind it to the sheet route. Import navigating from $app/stores, and set open to false when navigating.
` |
Beta Was this translation helpful? Give feedback.
2 replies
-
let open = false;
<Sheet.Root bind:open>
<Sheet.Content side="left">
<a
onclick={() => {
open = false;
}}
href="/about"
class="text-muted-foreground hover:text-foreground {$pageStore.route.id === '/about'
? 'font-bold text-sky-950'
: ''}">About</a
> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
huntabyte
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
How to programmatically open and close a Sheet? For example I use a Sheet as a sidebar in my project and I want the Sheet to close as soon as the user clicks on a link or when there is a change to the route.
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions