# Breakpoints

Shared viewport thresholds and responsive patterns for Zenos layouts and applications.

Zenos uses a mobile-first breakpoint scale shared by layout props and Tailwind utilities. Start with the narrowest useful layout, then add a breakpoint only when the content needs more room or a different structure.

## Scale

The pixel values assume the browser's standard 16px root size and are shown as a convenient reference. Zenos consumes Tailwind's `rem`-based default breakpoints rather than maintaining a separate set of device-specific thresholds.

`base` is a responsive-prop key, not a Tailwind prefix. It produces unprefixed styles that apply everywhere until a larger breakpoint overrides them.

## Mobile-first behavior

Breakpoint rules use `min-width`. A value begins at its breakpoint and remains active at larger widths until another value overrides it.

```tsx
<Grid columns={{ base: 1, md: 2, xl: 4 }} gap={{ base: "3", lg: "6" }}>
  {children}
</Grid>
```

This grid has one column by default, two columns from `md`, and four columns from `xl`. Its gap changes from `3` to `6` at `lg`. Omitted breakpoints inherit the last applicable value through CSS.

Always provide a usable `base` layout when the value must change responsively. Do not use `sm` as shorthand for mobile: `sm` starts at 640px, while the unprefixed value covers widths below it.

## Responsive layout props

Zenos layout primitives accept either a direct value or a responsive object for the properties they own. The public `Responsive<T>` type supports `base`, `sm`, `md`, `lg`, `xl`, and `2xl`.

```tsx
import { Container, Grid, GridSpan, Stack } from "@zentara-co/zenos-ui";

<Container size="xl">
  <Grid columns={{ base: 1, lg: 12 }} gap={{ base: "4", lg: "6" }}>
    <GridSpan columns={{ base: 1, lg: 8 }}>
      <MainContent />
    </GridSpan>
    <GridSpan columns={{ base: 1, lg: 4 }}>
      <SupportingPanel />
    </GridSpan>
  </Grid>

  <Stack
    direction={{ base: "column", sm: "row" }}
    align={{ base: "stretch", sm: "center" }}
    gap="3"
  >
    <PrimaryAction />
    <SecondaryAction />
  </Stack>
</Container>;
```

Prefer responsive props when a layout primitive owns the behavior. This keeps structure typed and makes the breakpoint decision visible at the call site.

## Tailwind utilities

Use the matching Tailwind prefixes for application-specific layout and decoration:

```tsx
<section className="px-4 py-6 md:px-6 lg:py-10">
  <div className="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4">{children}</div>
</section>
```

Unprefixed utilities are the base treatment. Prefixes add overrides at their minimum width. Keep related responsive classes close together so the progression can be read without searching across files.

## Choose breakpoints from content

Use the first breakpoint where the current composition stops working, not a presumed phone, tablet, or desktop model.

- Let text wrap before increasing the viewport requirement.
- Add columns only when each column retains a useful readable width.
- Move actions inline when their labels fit without crowding or truncation.
- Keep dense data horizontally scrollable when collapsing it would hide meaning.
- Prefer a container query for a reusable component whose layout depends on its parent rather than the viewport.
- Avoid adding a different layout at every breakpoint. Most interfaces need only one or two meaningful transitions.

The same viewport can contain a full-width page, a narrow side panel, and an embedded card. Viewport breakpoints cannot describe all three component contexts reliably.

## CSS before JavaScript

Use responsive props, media queries, or utility prefixes for presentation. CSS responds before paint, works during server rendering, and avoids maintaining duplicate viewport state.

Use viewport hooks only when width must change behavior that CSS cannot express, such as selecting a different interaction model or coordinating imperative third-party code.

| API                           | Default range                      |
| ----------------------------- | ---------------------------------- |
| `useMobileMode()`             | Below `md`, through `767px`        |
| `useTabletMode().isPortrait`  | Through `1023px`, including mobile |
| `useTabletMode().isLandscape` | `1024px` through `1279px`          |
| `useTabletMode().isAnyTablet` | Through `1279px`                   |

```tsx
import { useMobileMode } from "@zentara-co/zenos-ui";

function ResultsInteraction() {
  const isMobile = useMobileMode();

  return isMobile ? <ResultsSheet /> : <ResultsPopover />;
}
```

The hooks read the visual viewport when available and subscribe to resize changes. Their server value is non-mobile, so the first client render may update after hydration. Do not use them merely to toggle CSS layout or hide presentational content. See [Hooks](/hooks/) for their complete APIs and SSR behavior.

## Show, hide, and reorder responsibly

Responsive presentation must preserve meaning and interaction:

- Do not hide essential actions, errors, or instructions at narrow widths.
- Avoid rendering duplicate interactive controls for different breakpoints unless the inactive copy is removed from both layout and the accessibility tree.
- Keep DOM order logical even when Grid or Flexbox changes visual placement.
- Preserve focus when changing between responsive interaction patterns.
- Prefer wrapping and reflow over truncating meaningful content.

## Test the transitions

Test around the boundary, not only at the named width. For an `md` change, verify at 767px, 768px, and a comfortably wider size.

Also test:

- browser zoom up to 200%
- increased default font size
- long and translated labels
- open menus, dialogs, and validation messages
- keyboard focus order after reflow
- horizontal overflow in tables, charts, and code examples
- resizing while temporary UI is open

Breakpoints organize available space; they do not replace resilient content, intrinsic sizing, or accessible reflow.

Source: https://zenos-ui.pages.dev/foundations/breakpoints/