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

## Available hooks

<div className="zenos-feature-grid not-content">
  <a className="zenos-feature" href="/hooks/use-headings/">
    <strong>useHeadings</strong>
    Read article headings as navigation entries and update them when the document changes.
  </a>
  <a className="zenos-feature" href="/hooks/use-scroll-spy/">
    <strong>useScrollSpy</strong>
    Track the reached heading in a document or independent scroll pane.
  </a>
  <a className="zenos-feature" href="/hooks/use-theme/">
    <strong>useTheme</strong>
    Persist and synchronize light or dark theme state, including the document root and system
    preference.
  </a>
  <a className="zenos-feature" href="/hooks/use-direction/">
    <strong>useDirection</strong>
    Read the nearest left-to-right or right-to-left component behavior context.
  </a>
  <a className="zenos-feature" href="/hooks/use-mobile-mode/">
    <strong>useMobileMode</strong>
    Detect whether the visual viewport is at or below a configurable maximum width.
  </a>
  <a className="zenos-feature" href="/hooks/use-tablet-mode/">
    <strong>useTabletMode</strong>
    Read the portrait, landscape, and combined responsive modes used by application layouts.
  </a>
</div>

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

```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](/foundations/breakpoints/) for the shared viewport scale.

## 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:

- `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](/foundations/dark-mode/) includes the initialization pattern.

## Scope

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.

Source: https://zenos-ui.pages.dev/hooks/