Hooks
Utilities for direction, theme state, and responsive interaction modes.
Zenos hooks expose the small pieces of client state that are shared by components and application shells. Import them from the public package boundary:
import { useDirection, useMobileMode, useTabletMode, useTheme } from "@zentara-co/zenos-ui";All public hooks are client-side React APIs. In frameworks with server and client component boundaries, call them from a client component.
Available hooks
Section titled “Available hooks”useHeadings Read article headings as navigation entries and update them when the document changes.
useScrollSpy Track the reached heading in a document or independent scroll pane.
useTheme Persist and synchronize light or dark theme state, including the document root and system preference.
useDirection Read the nearest left-to-right or right-to-left component behavior context.
useMobileMode Detect whether the visual viewport is at or below a configurable maximum width.
useTabletMode Read the portrait, landscape, and combined responsive modes used by application layouts.
Choose CSS first
Section titled “Choose CSS first”Use responsive layout props, Tailwind breakpoint utilities, or media queries for presentation. CSS responds before paint, works during server rendering, and avoids duplicating viewport state in JavaScript.
<Stack direction={{ base: "column", md: "row" }} gap="4"> {children}</Stack>Use a responsive hook only when viewport width must change behavior that CSS cannot express, such as choosing between a sheet and a popover or configuring an imperative third-party library. See Breakpoints for the shared viewport scale.
Server rendering
Section titled “Server rendering”Hooks that depend on browser APIs return a deterministic server value and update after mounting. Design the initial render so it remains valid before that update:
useDirectionreturns the nearest provider value, orltrwithout a provider.useMobileModereturnsfalseon the server.useTabletModereturns allfalseon the server.useThemereturns itsdefaultThemeon the server.
Do not render essential content only after a viewport hook becomes true. For theme, apply the persisted preference before first paint when possible to avoid a flash; the Dark mode guide includes the initialization pattern.
These hooks manage general UI concerns only. Keep requests, caching, permissions, analytics, and product workflow state in focused application-owned hooks near the feature that uses them.