Skip to content
Playground

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:

TSX
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.

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.

TSX
<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.

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:

  • useDirection returns the nearest provider value, or ltr without a provider.
  • useMobileMode returns false on the server.
  • useTabletMode returns all false on the server.
  • useTheme returns its defaultTheme on 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.