Skip to Content
BBRICKSv0.7.4
ShellOther

useAppShell

The surrounding AppShell's tier and nav sheet, or null outside one.

import { useAppShell } from '@ergasti/bricks';

Examples

Read the shell's state

A component under AppShell can ask which viewport tier the shell is in and whether the phone nav sheet is open (openNav opens it on phones); outside a shell the hook returns null.

Code
import { AppShell, useAppShell } from '@ergasti/bricks';
import { brandMark, brandNav } from './nav';

function TierProbe() {
  const shell = useAppShell();
  return <p>Inside the shell: tier <b>{shell?.tier ?? 'none'}</b>, sheet {shell?.navOpen ? 'open' : 'closed'}.</p>;
}

function Probe() {
  return (
    <AppShell brand={brandMark} nav={brandNav} activeId="home">
      <TierProbe />
    </AppShell>
  );
}

Signature

function useAppShell(): ShellState | null

Returns

ShellState | null

AppShell · EmptyView · ScreenErrorBoundary · UsageMeter

Source

src/shell/context.ts (line 16) on GitHub.

On this page