react
БесплатноБез исполняемых скриптовНе проверенBuilds token-driven React components with TypeScript and modern patterns. Use when creating React component libraries, integrating CSS custom properties, or…
Об этом скилле
React Component Patterns
Overview
Build accessible, token-driven React components following modern patterns. Covers styling approaches, TypeScript integration, composition patterns, and how to consume design tokens from the token skills.
When to Use
- Creating a React component library
- Building components that use design tokens
- Setting up a design system in React/Next.js
- Converting designs to React components
The Process
- Identify component type: Primitive, composite, or layout?
- Choose styling approach: CSS Modules, Tailwind, styled-components, or CSS-in-JS?
- Define props interface: TypeScript types with sensible defaults
- Implement with tokens: Use CSS custom properties or theme context
- Add accessibility: ARIA, keyboard handling, focus management
- Export properly: Named exports, types, and variants
Styling Approaches
| Approach | When to Use | Token Integration |
|---|---|---|
| CSS Modules | Build-time CSS, SSR-friendly | Import CSS with var(--token) |
| Tailwind | Utility-first, rapid development | Extend config with tokens |
| styled-components | Runtime theming, dynamic styles | ThemeProvider with tokens |
| Vanilla Extract | Type-safe, zero-runtime | Import tokens as TS objects |
| CSS Custom Properties | Framework-agnostic, simple | Direct var(--token) usage |
Project Structure
src/
├── components/
│ ├── primitives/ # Base components
│ │ ├── Button/
│ │ │ ├── Button.tsx
│ │ │ ├── Button.module.css
│ │ │ ├── Button.test.tsx
│ │ │ └── index.ts
│ │ ├── Input/
│ │ └── Text/
│ ├── composite/ # Composed components
│ │ ├── Card/
│ │ ├── Modal/
│ │ └── Dropdown/
│ └── layout/ # Layout components
│ ├── Stack/
│ ├── Grid/
│ └── Container/
├── tokens/
│ ├── colors.css
│ ├── spacing.css
│ └── index.css
├── hooks/
│ └── useTheme.ts
└── index.ts # Public exports
Component Patterns
Button Component
Button.tsx:
import { forwardRef, type ButtonHTMLAttributes, type ReactNode } from 'react';
import styles from './Button.module.css';
import { clsx } from 'clsx';
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
/** Visual style variant */
variant?: 'primary' | 'secondary' | 'ghost' | 'danger';
/** Size of the button */
size?: 'sm' | 'md' | 'lg';
/** Full width button */
fullWidth?: boolean;
/** Loading state - disables button and shows spinner */
loading?: boolean;
/** Icon before text */
leftIcon?: ReactNode;
/** Icon after text */
rightIcon?: ReactNode;
children: ReactNode;
}
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{
variant = 'primary',
size = 'md',
fullWidth = false,
loading = false,
leftIcon,
rightIcon,
disabled,
className,
children,
...props
},
ref
) => {
const isDisabled = disabled || loading;
return (
<button
ref={ref}
className={clsx(
styles.button,
styles[variant],
styles[size],
fullWidth && styles.fullWidth,
loading && styles.loading,
className
)}
disabled={isDisabled}
aria-busy={loading}
{...props}
>
{loading && <span className={styles.spinner} aria-hidden="true" />}
{leftIcon && <span className={styles.icon}>{leftIcon}</span>}
<span className={styles.label}>{children}</span>
{rightIcon && <span className={styles.icon}>{rightIcon}</span>}
</button>
);
}
);
Button.displayName = 'Button';
Button.module.css:
.button {
/* Layout */
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--spacing-xs);
/* Typography */
font-family: inherit;
font-weight: 500;
line-height: 1;
white-space: nowrap;
/* Interaction */
cursor: pointer;
user-select: none;
transition:
background-color 150ms ease,
border-color 150ms ease,
transform 100ms ease;
/* Reset */
border: 1px solid transparent;
border-radius: var(--radius-md);
}
.button:focus-visible {
outline: 2px solid var(--color-primary-500);
outline-offset: 2px;
}
.button:active:not(:disabled) {
transform: scale(0.98);
}
.button:disabled {
cursor: not-allowed;
opacity: 0.5;
}
/* Variants */
.primary {
background-color: var(--color-primary-500);
color: white;
}
.primary:hover:not(:disabled) {
background-color: var(--color-primary-600);
}
.secondary {
background-color: transparent;
border-color: var(--color-gray-300);
color: var(--color-gray-700);
}
.secondary:hover:not(:disabled) {
background-color: var(--color-gray-50);
border-color: var(--color-gray-400);
}
.ghost {
background-color: transparent;
color: var(--color-gray-700);
}
.ghost:hover:not(:disabled) {
backg
Установить react в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл react?
Builds token-driven React components with TypeScript and modern patterns. Use when creating React component libraries, integrating CSS custom properties, or building Next.js design system components with forwardRef and composition.
Как установить скилл react?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл react запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic