# Component Guide - Dish Planner
This guide documents the standardized UI components in the Dish Planner application. All components use Tailwind CSS with our custom color variables from the design system.
## Design System
### Colors
Our color palette is defined in `src/styles/theme/colors/root.css` and integrated into Tailwind via `tailwind.config.ts`:
- **Primary (Rose)**: `bg-primary`, `text-primary`, `border-primary` with shades 50-950
- **Secondary (Deluge)**: `bg-secondary`, `text-secondary`, `border-secondary` with shades 50-950
- **Accent (Malibu Blue)**: `bg-accent`, `text-accent`, `border-accent` with shades 50-950
- **Yellow (Gamboge)**: `bg-yellow`, `text-yellow`, `border-yellow` with shades 50-950
- **Gray (Ebony Clay)**: `bg-gray`, `text-gray`, `border-gray` with shades 100-950
- **Semantic Colors**:
- Danger (Alizarin Crimson): `bg-danger`, `text-danger`, `border-danger`
- Success (Spring Green): `bg-success`, `text-success`, `border-success`
- Warning (Burning Orange): `bg-warning`, `text-warning`, `border-warning`
## Components
### Button (`src/components/ui/Button.tsx`)
Unified button component supporting multiple variants, appearances, and states.
#### Props
```typescript
interface ButtonProps {
appearance?: 'solid' | 'outline' | 'text'; // Default: 'solid'
variant?: 'primary' | 'secondary' | 'accent' | 'danger'; // Default: 'primary'
size?: 'small' | 'medium' | 'large'; // Default: 'medium'
type?: 'button' | 'submit' | 'reset'; // Default: 'button'
href?: string; // For link buttons
icon?: ReactNode;
disabled?: boolean;
onClick?: () => void;
className?: string;
children: ReactNode;
}
```
#### Examples
```tsx
// Solid primary button
// Outline accent button with icon
}>
Add Item
// Text danger button
// Link button
}>
Back to Dishes
```
### Input (`src/components/ui/Input.tsx`)
Standardized text input component with label, error, and helper text support.
#### Props
```typescript
interface InputProps extends InputHTMLAttributes {
label?: string;
error?: string;
helperText?: string;
fullWidth?: boolean; // Default: true
}
```
#### Examples
```tsx
// Basic input with label
setEmail(e.target.value)}
required
/>
// Input with error
// Input with helper text
```
### Select (`src/components/ui/Select.tsx`)
Standardized select dropdown component.
#### Props
```typescript
interface SelectProps extends SelectHTMLAttributes {
label?: string;
error?: string;
helperText?: string;
fullWidth?: boolean; // Default: true
options: Array<{ value: string | number; label: string }>;
}
```
#### Example
```tsx
```
## Migration Guide
### From Old Button Components
The old button components have been removed. Use the unified `Button` component instead:
- `SolidButton` → `Button` with `appearance="solid"`
- `OutlineButton` → `Button` with `appearance="outline"`
- `SolidLinkButton` → `Button` with `appearance="solid"` and `href` prop
- `OutlineLinkButton` → `Button` with `appearance="outline"` and `href` prop
### Custom CSS Classes to Tailwind
Replace custom CSS classes with Tailwind utilities:
- `background-red` → `bg-primary`
- `background-secondary` → `bg-secondary`
- `font-size-18` → `text-lg`
- `text-accent-blue` → `text-accent`
- `border-accent` → `border-accent`
## Best Practices
1. **Use semantic color names**: Prefer `text-primary`, `bg-danger` over hardcoded colors
2. **Consistent spacing**: Use Tailwind's spacing scale (p-2, p-4, etc.)
3. **Responsive design**: Consider mobile-first responsive classes
4. **Accessibility**: Use proper ARIA attributes and semantic HTML
5. **Component reusability**: Always use the standardized components instead of creating custom styled elements
## Future Enhancements
Potential areas for further improvement:
- Migrate remaining inline-styled inputs to use the `Input` component
- Add dark mode support
- Create compound components for common patterns (e.g., FormGroup)
- Add animation utilities for better UX
- Implement a comprehensive form validation system