Overview
The @trendingsociety/ui package is the single source of truth for all UI components. It contains 42 shadcn/ui components consolidated from across the monorepo.
Rule: Never duplicate components in apps. Always import from @trendingsociety/ui.
Installation
Already included in all apps via workspace dependency:
{
"dependencies": {
"@trendingsociety/ui": "workspace:*"
}
}
Usage
import {
Button,
Card,
CardHeader,
CardTitle,
CardContent,
Dialog,
DialogTrigger,
DialogContent
} from '@trendingsociety/ui';
export function MyComponent() {
return (
<Card>
<CardHeader>
<CardTitle>Title</CardTitle>
</CardHeader>
<CardContent>
<Dialog>
<DialogTrigger asChild>
<Button>Open</Button>
</DialogTrigger>
<DialogContent>
Content here
</DialogContent>
</Dialog>
</CardContent>
</Card>
);
}
Available Components
Layout
| Component | Description |
|---|
Card | Container with header, content, footer |
Accordion | Expandable sections |
Tabs | Tabbed interface |
Separator | Visual divider |
ScrollArea | Custom scrollbar |
Collapsible | Toggle visibility |
| Component | Description |
|---|
Button | Primary action button |
Input | Text input field |
Textarea | Multi-line input |
Select | Dropdown selection |
Checkbox | Toggle option |
Switch | On/off toggle |
RadioGroup | Single selection |
Label | Form labels |
Form | React Hook Form wrapper |
Feedback
| Component | Description |
|---|
Alert | Inline messages |
Badge | Status indicators |
Progress | Loading progress |
Skeleton | Loading placeholder |
Toast | Notifications |
Tooltip | Hover hints |
Overlays
| Component | Description |
|---|
Dialog | Modal dialog |
Sheet | Slide-out panel |
Drawer | Bottom sheet |
Popover | Floating content |
AlertDialog | Confirmation modal |
Navigation
| Component | Description |
|---|
Sidebar | App navigation |
Breadcrumb | Path navigation |
DropdownMenu | Action menus |
Command | Command palette |
Data Display
| Component | Description |
|---|
Table | Data tables |
Avatar | User images |
Calendar | Date picker |
Chart | Recharts wrapper |
Data Table Components
| Component | Description |
|---|
DataTableColumnHeader | Sortable column headers |
DataTableFacetedFilter | Multi-select filters |
DataTablePagination | Page controls |
DataTableViewOptions | Column visibility |
Variants
<Button variant="default">Default</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="outline">Outline</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="destructive">Delete</Button>
<Button variant="link">Link</Button>
Never use variant="danger". Use variant="destructive" instead.
<Button size="default">Default</Button>
<Button size="sm">Small</Button>
<Button size="lg">Large</Button>
<Button size="icon">Icon</Button>
Common Patterns
Card with Actions
<Card>
<CardHeader className="flex flex-row items-center justify-between">
<CardTitle>Users</CardTitle>
<Button size="sm">Add User</Button>
</CardHeader>
<CardContent>
<Table>...</Table>
</CardContent>
</Card>
Confirmation Dialog
<AlertDialog>
<AlertDialogTrigger asChild>
<Button variant="destructive">Delete</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
<AlertDialogDescription>
This action cannot be undone.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={handleDelete}>Delete</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
import { Form, FormField, FormItem, FormLabel, FormControl, FormMessage } from '@trendingsociety/ui';
const schema = z.object({
email: z.string().email(),
name: z.string().min(2)
});
export function UserForm() {
const form = useForm({
resolver: zodResolver(schema)
});
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit">Submit</Button>
</form>
</Form>
);
}
Adding New Components
Check if it exists
Look in packages/ui/src/components/ first
Install via shadcn
cd packages/ui
npx shadcn@latest add [component]
Export from index
Add to packages/ui/src/index.ts
Use in apps
import { NewComponent } from '@trendingsociety/ui';
Icons
Use Lucide React or Tabler Icons:
import { Home, Settings, User } from 'lucide-react';
import { IconBrandShopify } from '@tabler/icons-react';
<Button>
<Home className="w-4 h-4 mr-2" />
Home
</Button>