Skip to content
Playground

useTabletMode

Track Zenos portrait and landscape application layout modes.

useTabletMode exposes the responsive modes used by wider application-shell behavior. These values describe viewport ranges, not detected hardware or physical device orientation.

TSX
import {  TABLET_LANDSCAPE_MAX_WIDTH,  TABLET_PORTRAIT_MAX_WIDTH,  useTabletMode,} from "@zentara-co/zenos-ui";
TSX
"use client"; import { useTabletMode } from "@zentara-co/zenos-ui"; export function WorkspaceNavigation() {  const { isPortrait, isLandscape, isAnyTablet } = useTabletMode();   if (isPortrait) return <CompactNavigation />;  if (isLandscape) return <CollapsibleNavigation />;  return <PersistentNavigation data-tablet-mode={isAnyTablet || undefined} />;}
ValueWidth rangeNotes
isPortrait0px–1023pxIncludes mobile widths; below the lg breakpoint
isLandscape1024px–1279pxFrom lg until immediately before xl
isAnyTablet0px–1279pxTrue when either responsive mode is active

The exported constants are:

TypeScript
TABLET_PORTRAIT_MAX_WIDTH = 1023;TABLET_LANDSCAPE_MAX_WIDTH = 1279;

The names describe Zenos layout modes. isPortrait does not read the Screen Orientation API, and isAnyTablet does not identify a user’s device. A narrow desktop window can enter the same mode.

TypeScript
interface TabletModeState {  isPortrait: boolean;  isLandscape: boolean;  isAnyTablet: boolean;}

TabletModeState is exported from @zentara-co/zenos-ui when application code needs to pass or adapt the complete result.

  • Reads window.visualViewport.width when available, otherwise window.innerWidth.
  • Rounds the viewport width before selecting a range.
  • Subscribes to window and visual-viewport resize events.
  • Removes every listener when the component unmounts.

All three values are false when browser globals are unavailable. The hook updates after mounting, so a viewport at or below 1279px can switch interaction patterns on the client.

Prefer responsive layout props or utilities when CSS can express the result. Use this hook for behavioral changes, keep the initial desktop behavior valid, and preserve focus when switching modes.

See Breakpoints for the shared scale and useMobileMode for a single configurable compact-width boolean.