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.
Import
Section titled “Import”import { TABLET_LANDSCAPE_MAX_WIDTH, TABLET_PORTRAIT_MAX_WIDTH, useTabletMode,} from "@zentara-co/zenos-ui";"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} />;}Ranges
Section titled “Ranges”| Value | Width range | Notes |
|---|---|---|
isPortrait | 0px–1023px | Includes mobile widths; below the lg breakpoint |
isLandscape | 1024px–1279px | From lg until immediately before xl |
isAnyTablet | 0px–1279px | True when either responsive mode is active |
The exported constants are:
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.
Return type
Section titled “Return type”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.
Behavior
Section titled “Behavior”- Reads
window.visualViewport.widthwhen available, otherwisewindow.innerWidth. - Rounds the viewport width before selecting a range.
- Subscribes to window and visual-viewport resize events.
- Removes every listener when the component unmounts.
Server rendering
Section titled “Server rendering”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.