react-frontend-patterns
/react-frontend-patterns
Przegląda i buduje komponenty React 19 z Tailwind CSS i shadcn/ui, z naciskiem na dostępność, formularze i stan aplikacji.
- Autor
- seandkendall ↗
- Repozytorium
- kiro-config ↗
- Licencja
- Apache-2.0
- Ostatnia zmiana repozytorium
- 26.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 26.10.2026, bez odwołań do wycofanych modeli i API.
Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.
Co robi i kiedy
Przegląda i buduje komponenty React 19 z Tailwind CSS i shadcn/ui, z naciskiem na dostępność, formularze i stan aplikacji.
Oryginalny opis (EN)
React 19+, TypeScript, Tailwind CSS, shadcn/ui component patterns, accessibility, forms, state management. Use when building or reviewing React components, pages, or frontend architecture.
Jak działa
- Component Template
- Form Pattern (react-hook-form + zod)
- State Management
- Accessibility Checklist
- Responsive Breakpoints
- data-testid Selectors (MANDATORY — for Playwright)
Podgląd SKILL.md
---
name: react-frontend-patterns
description: React 19+, TypeScript, Tailwind CSS, shadcn/ui component patterns, accessibility, forms, state management. Use when building or reviewing React components, pages, or frontend architecture.
---
# React Frontend Patterns
## Component Template
```tsx
/** Dashboard page — displays financial overview with charts and recent transactions. */
interface DashboardProps {
userId: string;
}
export function Dashboard({ userId }: DashboardProps) {
const { data, isLoading, error } = useQuery({
queryKey: ['dashboard', userId],
queryFn: fetchDashboard,
});
if (isLoading) return <DashboardSkeleton />;
if (error) return <ErrorState message="Failed to load dashboard" />;
if (!data) return <EmptyState message="No data yet" />;
return (
<main data-testid="dashboard-page">
<h1 className="text-2xl font-bold">Dashboard</h1>
{/* content */}
</main>
);
}
```
## Form Pattern (react-hook-form + zod)
```tsx
const schema = z.object({
amount: z.number().positive('Must be greater than 0'),
description: z.string().min(1, 'Required'),
});
function TransactionForm() {
const {
register,
handleSubmit,
formState: { errors },
} = useForm({ resolver: zodResolver(schema) });
return (
<form onSubmit={handleSubmit(onSubmit)} data-testid="transaction-form">
<label htmlFor="amount">Amount</label>
<input
id="amount"
type="number"
aria-invalid={!!errors.amount}
aria-describedby="amount-error"
{...register('amount', { valueAsNumber: true })}
/>
{errors.amount && (
<p id="amount-error" role="alert">
{errors.amount.message}
</p>
)}
</form>
);
}
```
## State Management
- Server state: TanStack Query (useQuery, useMutation, optimistic updates)
- Client state: Zustand for global UI state, React Context for theme/auth
- Never prop-drill more than 2 levels
## Accessibility Checklist
- All interactive elements keyboard-reachable (Tab, Enter, Space, Escape)
- Visible focus indicators — never `outline: none` without replacement
- Color contrast: 4.5:1 normal text, 3:1 large text
- All images have `alt` text (decorative: `alt=""`)
- Form inputs have `<label>` or `aria-label`
- Error messages use `role="alert"`
- NEVER use browser `alert()`, `confirm()`, or `prompt()` dialogs — for ANY purpose: informational messages, error/success notifications, confirmations, or approval prompts. Always use a modal component instead (shadcn/ui `Dialog` for messages/notifications, `AlertDialog` for confirmations/approvals that block on a user decision)
## Responsive Breakpoints
Four tiers, covering phones through TV/dashboard displays (kept in sync with `tech.md` and `accessibility-standards.md`):
- Mobile (phones): 375px (default, mobile-first)
- Tablet / small laptop: `md:` (768px)
- Desktop / widescreen: `lg:` (1280px)
- TV / dashboard (large displays, kiosks, car dashboards): `2xl:` (1920px)
- Touch targets: minimum 44x44px on mobile
## data-testid Selectors (MANDATORY — for Playwright)
`data-testid` attributes are **REQUIRED** on every interactive element. Playwright tests are non-negotiable in this codebase, and CSS/class selectors break tests when styles change.
**Required on:**
- Every `<button>` / `<a>` (clickable)
- Every `<input>` / `<select>` / `<textarea>` (user input)
- Every `<form>` (submission target)
- Every page-level container (test entry point)
- Every error/success message (assertion target)
- Every modal / dialog (visibility check)
- Every loading indicator (race-condition guard)
**Naming pattern:** `data-testid="<entity>-<action>"` or `data-testid="<entity>-<role>"`
| Element | Pattern | Example |
| -------------- | ------------------------ | ------------------------------------ |
| Submit button | `<entity>-submit` | `data-testid="invoice-submit"` |
| Cancel button | `<entity>-cancel` | `data-testid="invoice-cancel"` |
| Form input | `<entity>-<field>-input` | `data-testid="invoice-amount-input"` |
| Error message | `<entity>-error` | `data-testid="invoice-error"` |
| Page container | `<page>-page` | `data-testid="dashboard-page"` |
| List item | `<entity>-row-<id>` | `data-testid="invoice-row-123"` |
| Modal | `<entity>-modal` | `data-testid="delete-confirm-modal"` |
**Rules:**
- Never use class selectors, IDs, or tag selectors in Playwright — `page.getByTestId('...')` only
- Keep selectors **stable** — only change them when the element's purpose changes, not when styles or DOM hierarchy change
- Avoid dynamic IDs like `data-testid="btn-${randomId}"` — use stable entity identifiers
- One `data-testid` per element — don't reuse the same value on multiple elements (Playwright will throw a strict-mode violation)
- For lists, include the row's unique identifier so individual rows can be selected
**Code review enforcement:** PRs that add interactive elements WITHOUT `data-testid` selectors should be rejected. The testing agent will flag missing selectors automatically when it sees a component without coverage.
Wersje
W bazie nie ma innych skilli o nazwie react-frontend-patterns.
Migawka bazy z 13.11.2026 · wersja paczki 975e8b98a291 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100frontend-react
Wspiera tworzenie aplikacji React z Next.js, React Server Components, Tailwind CSS i shadcn/ui oraz złożonym zarządzaniem stanem. - 100frontend-react
Wspiera tworzenie aplikacji React z Next.js, React Server Components, Tailwind CSS i shadcn/ui oraz obsługę złożonego zarządzania stanem. - 100senior-frontend
Buduje komponenty React i Next.js w TypeScript i Tailwind, optymalizuje wielkość bundla i sprawdza dostępność interfejsu. - 95senior-frontend
Pomaga w projektach React, Next.js i Tailwind CSS: komponenty, wydajność, analiza bundla, dostępność i przegląd kodu. - 90senior-frontend
Wspiera frontend w React, Next.js, TypeScript i Tailwind CSS: komponenty, wydajność Next.js, analiza rozmiaru bundli, scaffolding, dostępność i przegląd kodu. - 95senior-frontend
Wspiera pracę nad frontendem w React, Next.js, TypeScript i Tailwind CSS: komponenty, wydajność, analiza rozmiaru bundli, dostępność i przegląd kodu.