Skip to content

UI Components

The @simplemodule/ui package provides a comprehensive set of React components built on Radix UI primitives with Tailwind CSS styling. It follows the shadcn/ui approach -- components live in your workspace as source code, not as an opaque npm dependency.

Package Overview

The package is located at packages/SimpleModule.UI/ and uses two export paths:

ts
// Import components
import { Button, Card, Dialog } from '@simplemodule/ui';

// Import utilities
import { cn } from '@simplemodule/ui/lib/utils';

The cn Utility

The cn function combines clsx and tailwind-merge to safely merge Tailwind classes:

ts
import { cn } from '@simplemodule/ui/lib/utils';

<div className={cn('p-4 bg-surface', isActive && 'bg-primary-subtle', className)} />

This avoids class conflicts (e.g., p-4 and p-2 don't both end up in the DOM -- tailwind-merge resolves them).

Available Components

Layout

ComponentDescription
ContainerCentered max-width container with variant sizes
GridCSS grid wrapper with configurable columns
StackFlexbox stack (vertical/horizontal) with gap control
PageShellFull page wrapper with title, description, and breadcrumbs
PageHeaderPage header with title and actions slot
SectionSemantic section wrapper
SeparatorVisual divider (horizontal or vertical)
AspectRatioMaintains a fixed aspect ratio for content
ScrollAreaCustom scrollbar container
ResizableResizable panel layout (ResizablePanel, ResizableHandle, ResizablePanelGroup)

Data Display

ComponentDescription
CardSurface container (Card, CardHeader, CardContent, CardFooter, CardTitle, CardDescription)
TableStyled table (Table, TableHeader, TableBody, TableRow, TableHead, TableCell)
DataGridFeature-rich data table with sorting, filtering, and pagination
DataGridPageFull-page data grid with built-in search and actions
BadgeInline status indicator with variants
AvatarUser avatar with image and fallback
HoverCardCard shown on hover
TooltipContextual tooltip
CalendarDate calendar display
ChartRecharts wrapper with theming (ChartContainer, ChartTooltip, ChartLegend)
SkeletonLoading placeholder
SpinnerLoading spinner with size variants
ProgressProgress bar
ComponentDescription
BreadcrumbBreadcrumb navigation (Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator)
TabsTab navigation (Tabs, TabsList, TabsTrigger, TabsContent)
SidebarApplication sidebar (Sidebar, SidebarHeader, SidebarContent, SidebarMenu, SidebarMenuItem, etc.)
DropdownMenuDropdown menu (DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, etc.)
CommandCommand palette / search (Command, CommandInput, CommandList, CommandItem, etc.)
PopoverFloating content panel

Forms

ComponentDescription
ButtonButton with variants (default, destructive, outline, secondary, ghost, link)
InputText input with variants
TextareaMulti-line text input
CheckboxCheckbox input
RadioGroupRadio button group (RadioGroup, RadioGroupItem)
SelectDropdown select (Select, SelectTrigger, SelectValue, SelectContent, SelectItem)
SwitchToggle switch
SliderRange slider
LabelForm label
FieldForm field wrapper with label, description, and error (Field, FieldGroup, FieldDescription, FieldError)
DatePickerDate picker combining calendar and popover
ToggleToggle button
ToggleGroupGroup of toggle buttons

Feedback

ComponentDescription
AlertAlert message with variants (Alert, AlertTitle, AlertDescription)
DialogModal dialog (Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter)
SheetSlide-out panel (Sheet, SheetTrigger, SheetContent, SheetHeader, SheetTitle, SheetDescription)
ToastToast notification (Toast, ToastProvider, ToastViewport, ToastTitle, ToastDescription, ToastAction)
AccordionCollapsible content sections (Accordion, AccordionItem, AccordionTrigger, AccordionContent)
CollapsibleSingle collapsible section

Usage Examples

Page with Cards

tsx
import { Card, CardContent, PageShell } from '@simplemodule/ui';
import type { Product } from '../types';

export default function Browse({ products }: { products: Product[] }) {
  return (
    <PageShell title="Products" description="Browse the product catalog.">
      <div className="space-y-3">
        {products.map((p) => (
          <Card key={p.id}>
            <CardContent className="flex justify-between items-center">
              <span className="font-medium">{p.name}</span>
              <span className="text-text-muted">${p.price.toFixed(2)}</span>
            </CardContent>
          </Card>
        ))}
      </div>
    </PageShell>
  );
}

Form with Field Components

tsx
import { Button, Field, FieldError, FieldGroup, Input, Label } from '@simplemodule/ui';

function CreateForm() {
  return (
    <form>
      <FieldGroup>
        <Field>
          <Label>Product Name</Label>
          <Input name="name" placeholder="Enter product name" />
          <FieldError>Name is required</FieldError>
        </Field>
        <Button type="submit">Create Product</Button>
      </FieldGroup>
    </form>
  );
}

Data Grid Page

tsx
import { DataGridPage } from '@simplemodule/ui';

export default function Manage({ products }) {
  return (
    <DataGridPage
      title="Products"
      description="Manage your product catalog."
      columns={columns}
      data={products}
    />
  );
}

Dependencies

The UI package relies on these key dependencies:

  • Radix UI -- Accessible, unstyled primitives (dialog, dropdown, select, tabs, etc.)
  • class-variance-authority (CVA) -- Type-safe component variants
  • clsx + tailwind-merge -- Class name composition
  • cmdk -- Command palette
  • react-day-picker -- Calendar and date picker
  • recharts -- Charting library

React and React-DOM are peer dependencies -- they are provided by the host application, not bundled.

Next Steps

Released under the MIT License.