Shopware Design

useMtApp

Usage

useMtApp gives any component below App access to the shell state: whether the mobile layout is active, which drawer is open and which theme applies, plus functions to open and close drawers and to set the theme. Outside of a shell it returns inert defaults, so components that use it keep working on their own.

import { useMtApp } from "@shopware-ag/meteor-component-library";

const { isMobile, activeDrawer, openDrawer, closeDrawer } = useMtApp();

API

Return value

MemberTypeDescription
isMobileReadonly<Ref<boolean>>Whether the shell uses the mobile layout with off-canvas sidebars.
activeDrawerReadonly<Ref<"start" | "end" | null>>The sidebar that is open as a drawer. Always null in the desktop layout.
themeReadonly<Ref<Theme>>The theme preference: "light", "dark" or "system".
resolvedThemeReadonly<Ref<ResolvedTheme>>The applied theme after resolving "system".
scrollContainerReadonly<Ref<HTMLElement | null>>The content element that scrolls, for scrolling programmatically or restoring positions with a router other than Vue Router. null outside of a shell.
openDrawer(side: "start" | "end") => voidOpens the drawer of the given side. Does nothing in the desktop layout or for an empty or hidden sidebar.
closeDrawer() => voidCloses the open drawer.
setTheme(theme: Theme) => voidSets the theme preference. With a controlled theme prop on the shell this only emits update:theme.
  • useMtAppRegions: when a view should hide the header or sidebars, for example for a fullscreen route.
  • useTheme: when a component outside the shell manages or reads the theme preference.