---
name: strongtie-react-practices
description: "Apply React best practices and web-interface guidelines when building apps that consume @strongtie/design-system — accessibility, focus, forms UX, animation, performance, loading states, and dark mode. Use when: (1) Building or reviewing an app that consumes the design system, (2) Implementing forms or data fetching in a consuming app, (3) Ensuring accessibility and interaction quality."
---

# React & Web Interface Best Practices for Consuming Apps

Guidance for developers building and maintaining **apps that consume `@strongtie/design-system`** —
assembling the published components into pages, screens, and features. It is the app-side companion
to the authoring skills, not a replacement for them.

## When to use this skill

Reach for it when you are working in an application that depends on `@strongtie/design-system`:
composing published components into a screen, wiring up a form, deciding where data and state live,
or reviewing that work for accessibility and interaction quality. The through-line is that you are a
*consumer* of the design system — you import its components, you do not edit them.

## When NOT to use this skill

Do not use it to author the library itself. If your change lands in `packages/design-system/src/`,
you want `strongtie-component` for the two-layer component pattern, `strongtie-test` for the test
suite, and `strongtie-docs` for JSDoc/story/MDX/registry. In particular, the ref and component-typing
rules for *building* a primitive live in `strongtie-component`; this skill only tells a consuming app
how to *use* what those primitives already expose. And the app-stack recommendations below
(TanStack Query, Zustand) are suggestions for consuming apps — they are not part of this repo, so do
not treat them as design-system requirements.

## React 19 and the Compiler

**Let the React Compiler own memoization — do not hand-write it.** This project builds with the React
Compiler, which inserts memoization for you, so `useMemo`, `useCallback`, and `React.memo` are noise
that the compiler already handles; adding them by hand fights the tool and buries the one place a
manual memo would ever be justified. `React.lazy` is a different tool for a different job (code
splitting, not memoization) and stays. When you genuinely need it, reach for it; otherwise trust the
compiler and keep the component plain.

**Treat `ref` as an ordinary prop — there is no `forwardRef` in a React 19 consuming app.** React 19
passes `ref` straight through as a normal prop, so a component that forwards a ref just declares and
passes it; wrapping it in `forwardRef` is React-18 muscle memory that adds a layer for nothing. This
matches how the library is authored — the design-system primitives take `ref` as a plain prop — so
your app code and the components it imports agree. (The library-authoring side of this rule, and the
`ComponentProps` typing that goes with it, is owned by `strongtie-component`; here it is enough to
know that ref forwarding needs no ceremony.)

## Where state and data live

**Put server data in a cache, not in `useState`.** The most common state bug in a growing app is a
copy of an API response living in component state, because the copy and the source diverge on the
next refetch and nothing tells you which is stale. Server data belongs in a server-cache library;
local UI state belongs in `useState`; session-wide values (auth, tenant, theme) belong in Context;
and a dedicated store is a last resort for cross-component client state that Context is measurably
too slow for. This split is a recommendation for consuming apps — TanStack Query and Zustand are not
dependencies of this repo (note that `@tanstack/react-table`, which *is* a dependency, is an
unrelated table primitive), so adopt them per app, and see
[references/data-and-forms.md](references/data-and-forms.md) for the query-key factory, custom query
hooks, optimistic-update, and error-routing patterns.

**Reach for React Hook Form + Zod once a form earns it, and lean on `useState` until then.** Forms
with validation or more than a few fields are where hand-rolled state turns into a maintenance sink;
React Hook Form plus a Zod schema (both, with `@hookform/resolvers`, are real dependencies in this
repo) give you validation and typing from a single source of truth. Below that threshold — a couple
of fields, no rules — the library is more machinery than the job needs. The schema, resolver wiring,
and the field-count decision table are in [references/data-and-forms.md](references/data-and-forms.md).

## Accessibility is a build requirement, not a polish pass

**An icon-only control needs an accessible name, and the icon is not one.** A button whose only child
is a glyph reads to a screen reader as an unlabeled button — the user hears nothing about what it
does, which for a destructive action is a trap, not an inconvenience. Give it `aria-label`, or a
visually hidden `sr-only` label; never ship the bare-icon version:

```tsx
// REQUIRED — accessible name via aria-label
<Button variant="ghost" size="icon" aria-label="Delete project">
  <Trash2 className="h-4 w-4" />
</Button>

// NEVER — no accessible name
<Button variant="ghost" size="icon">
  <Trash2 className="h-4 w-4" />
</Button>
```

**The rest of accessibility is a small set of non-negotiables, and each one has a user behind it.**
Form inputs need real labels (a placeholder is not a label — it vanishes on focus and is invisible to
assistive tech); images need meaningful `alt`, or `alt=""` when they are decorative so a screen
reader skips them; every interactive element must be reachable and operable by keyboard, because a
mouse is not the only pointer; and color must never be the *only* signal of state, or you have hidden
that state from anyone who cannot distinguish the two colors.

**Keep focus visible, and never remove it without replacing it.** Interactive elements need a visible
focus indicator (`focus-visible:ring-*`), and `outline-none` with no replacement leaves keyboard
users with no idea where they are on the page. Prefer `:focus-visible` over `:focus` so the ring
appears for keyboard navigation but not on a mouse click, which is what users expect.

## Interaction and interface quality

**Design forms around how people actually fill them out.** Inputs want `autocomplete` and a
meaningful `name`, the right `type`/`inputmode` (`email`, `tel`, `url`, `number`) so mobile keyboards
match the field, and labels that are clickable via `htmlFor` or by wrapping the control. Show errors
inline next to the field and move focus to the first error on submit; warn before navigating away
from unsaved changes; disable spellcheck on emails, codes, and usernames; and keep the submit button
enabled until the request actually starts, then show a spinner. Never block paste — it is the single
most common way to break a password or coupon field for real users.

**Animate only what the compositor can cheaply move, and honor the user who asked for less.** Restrict
transitions to `transform` and `opacity`, list the properties explicitly instead of `transition: all`
(which animates properties you did not mean to and triggers layout), and make animations interruptible
so they respond to input mid-flight. Always honor `prefers-reduced-motion` — a user who set it may
get motion sick from the animation you find delightful.

**Spend typographic care where it shows.** Use real typographic characters — `…` not three dots,
curly quotes over straight ones — and non-breaking spaces to keep units with their numbers
(`10&nbsp;MB`, `⌘&nbsp;K`). Apply `font-variant-numeric: tabular-nums` to number columns so digits
line up, and `text-wrap: balance` on headings so they do not leave a lonely last word. None of this is
decoration; it is the difference between text that reads as considered and text that reads as a first
draft.

**Treat performance as something you protect, not something you add later.** Virtualize lists past
~50 items, keep layout reads (`getBoundingClientRect`, `offsetHeight`) out of render, and prefer
uncontrolled inputs — a controlled input that does real work per keystroke is a jank source. Give
images explicit `width` and `height` to prevent layout shift, lazy-load below-fold images, and use
Suspense for code splitting. The consequence of skipping these is not a slower app in the abstract; it
is a visibly janky one on the mid-range device most users actually have.

**Never leave a loading, error, or empty state unhandled — each is a real thing a user will see.**
Show a Skeleton when the layout is known and you are preventing shift, a Spinner when the layout is
unpredictable or the load is action-triggered, and always provide all three states: loading, an error
state with a retry, and an empty state with a call to action. A screen that renders nothing while
data loads reads as broken, and an error with no way forward reads as abandonment.

**Put durable state in the URL and let the platform do its job.** Filters, tabs, and pagination
belong in query params so a link is shareable and the back button works; real links use `<a>`/`<Link>`
so Cmd/Ctrl-click opens a new tab; and destructive actions need a confirmation or an undo window.
On touch, set `touch-action: manipulation` to kill the double-tap-zoom delay and `overscroll-behavior:
contain` in modals and drawers so scrolling does not leak to the page behind them. Use `autoFocus`
sparingly — desktop only, one primary input — because on mobile it yanks up the keyboard and hides
the context the user needed.

**Make dark mode a real mode, not an inverted afterthought.** Set `color-scheme: dark` on `<html>` so
native controls and scrollbars match, and keep `<meta name="theme-color">` in step with the page
background so the browser chrome does not flash the wrong color.

## Content and copy

**Write UI copy that tells the user what happened and what to do next.** Use the active voice
("Install the CLI", not "The CLI will be installed"), Title Case for headings and buttons, and
specific button labels ("Save API Key", not "Continue") so the action is legible without context.
Every error message should name a fix or a next step — an error that only reports failure leaves the
user stuck with no move.

## Anti-patterns to avoid

- `user-scalable=no` (disabling zoom is an accessibility failure)
- `transition: all`
- `outline-none` without a `focus-visible` replacement
- `<div>` with a click handler where a `<button>` belongs
- Images without dimensions
- Form inputs without labels
- Icon buttons without `aria-label`
- Hardcoded date/number formats — use `Intl.*`
- API responses copied into `useState`

## Before you call a screen done

- [ ] Named exports (not default)
- [ ] Loading state handled (Skeleton or Spinner)
- [ ] Error state handled (with retry)
- [ ] Empty state handled (with a call to action)
- [ ] Icon-only buttons have `aria-label`
- [ ] Form inputs have labels
- [ ] Focus states visible; no bare `outline-none`
- [ ] Uses `@strongtie/design-system` / registry primitives where applicable
- [ ] Uses `cn()` for conditional classes and `@/` import aliases

## Related skills

This skill is the consuming-app side. To author the components you are consuming, see
`strongtie-component`; for their tests, `strongtie-test`; for their docs, `strongtie-docs`; and for
project lint/format setup, `strongtie-style-consistency`.

## Reference

- Data fetching and forms (longer patterns): [references/data-and-forms.md](references/data-and-forms.md)
- Design Standards: https://design.strongtie.io/design-standards
- Code Examples: https://design.strongtie.io/design-standards-examples
- AGENTS.md Template: https://design.strongtie.io/agents-template
