useAppShellMobile @astryx-svelte/core v0.3.0 · AppShell

Usage

Hook for reading and controlling AppShell mobile navigation state from descendants of AppShell. Use it for custom mobile nav triggers, closing the drawer after route changes, or coordinating AppShell-adjacent mobile experiences with the same breakpoint used by mobile nav.
ts
import { AppShell } from '@astryx-svelte/core';

Best practices

GuidancePractices
DoUse inside the AppShell tree when building custom mobile navigation controls, route-aware nav items, or UI that should update at the same breakpoint as AppShell mobile nav.
DoPrefer MobileNavToggle for the standard hamburger trigger: use this hook when you need custom placement, styling, or extra behavior.
DoCall closeMobileNav after a custom mobile nav item changes route so the drawer dismisses cleanly.
Don'tUse as a general responsive primitive when the UI is not inside AppShell or does not need to align with AppShell mobile nav: use useMediaQuery instead.
Don'tAssume it throws outside AppShell. The hook returns safe defaults and no-op callbacks when no provider is present.

Returns

FieldTypeDefaultDescription
isMobile booleanWhether the current viewport is below the AppShell mobile navigation breakpoint. Use this to synchronize AppShell-adjacent mobile UI with the same breakpoint as mobile nav.
isMobileNavOpen booleanWhether the AppShell-managed mobile navigation drawer is open.
mobileNavId stringDOM id of the mobile navigation drawer, set by AppShell. Point aria-controls of a custom toggle at this so screen-reader users know which element the toggle expands. Undefined outside an AppShell that manages the drawer.
toggleMobileNav () => voidToggle the AppShell-managed mobile navigation drawer. No-ops when mobile nav is disabled.
openMobileNav () => voidOpen the AppShell-managed mobile navigation drawer. No-ops when mobile nav is disabled.
closeMobileNav () => voidClose the AppShell-managed mobile navigation drawer.
isMobileNavEnabled booleanWhether AppShell mobile navigation is enabled and managed by AppShell. False when mobileNav is false, there is no nav content, or a fully custom mobileNav ReactNode owns the drawer.
hasAutoToggle booleanWhether AppShell auto-toggle behavior is enabled. False when mobileNav hasToggle is set to false; combine with isMobile and isMobileNavEnabled before rendering custom toggles.

Examples

Common configurations, variations, and states.
useAppShellMobile — Custom Mobile Trigger
Custom mobile navigation trigger built with useAppShellMobile. The trigger consumes the surrounding AppShell context instead of rendering its own shell.