Skip to content

useAppShellMobile

@astryxdesign/core v0.7.1 · useAppShellMobile

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 { useAppShellMobile } from '@astryx-vue/core'
vue
<script setup lang="ts">
import { useAppShellMobile } from '@astryx-vue/core'

const { isMobile, isMobileNavEnabled, mobileNavId, openMobileNav } = useAppShellMobile()
</script>

<template>
  <button
    v-if="isMobile && isMobileNavEnabled"
    type="button"
    :aria-controls="mobileNavId"
    @click="openMobileNav"
  >
    Open navigation
  </button>
</template>

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.

Examples ​

Common configurations, variations, and states.

useAppShellMobile — Custom Mobile Trigger

No active AppShell mobile navigation context was detected. This hook returns safe defaults outside AppShell, or when the surrounding AppShell has mobile navigation disabled.

Custom mobile navigation trigger built with useAppShellMobile. The trigger consumes the surrounding AppShell context instead of rendering its own shell.