Primitive UI components built on Radix UI with Tailwind CSS styling.
bun add @spacedrive/primitives @spacedrive/tokens
# or
npm install @spacedrive/primitives @spacedrive/tokensPeer dependencies:
react^18.0.0 || ^19.0.0react-dom^18.0.0 || ^19.0.0tailwindcss^4.1.0
-
Configure your CSS entrypoint
@import '@spacedrive/tokens/theme';
-
Import CSS
@import '@spacedrive/tokens/css';
import { Button, Card, Dialog, Input, Badge } from '@spacedrive/primitives';
function MyComponent() {
return (
<Card>
<CardHeader>
<CardTitle>Welcome</CardTitle>
</CardHeader>
<CardContent className="space-y-4">
<Input placeholder="Enter your name" />
<Button>Get Started</Button>
</CardContent>
</Card>
);
}- Button - Multiple variants (default, subtle, outline, dotted, gray, accent, colored, bare)
- Input - Form input with error states
- Checkbox - Accessible checkbox with Radix
- Switch - Toggle switch with 3 sizes
- Slider - Range slider with marks support
- RadioGroup - Radio button groups
- Dialog - Modal dialogs with animations
- Popover - Floating content panels
- Tooltip - Hover tooltips
- DropdownMenu - Contextual menus
- ContextMenu - Right-click menus
- Tabs - Tabbed interfaces
- Select - Dropdown selects
- Dropdown - Simple expanding dropdowns
- Badge - Status badges (6 variants, 2 sizes)
- Card - Container with header/content/footer
- Banner - Alert banners (5 variants)
- Toast - Notification toasts
- Loader - Loading spinners and dots
- Divider - Horizontal/vertical dividers
- Typography - Text components (6 heading, 3 body)
- Shortcut - Keyboard shortcut display
- NumberStepper - Increment/decrement with min/max
- FilterButton - Toggle buttons for filters
- ToggleGroup - Radio-like button groups
- SearchBar - Search inputs with icons
- ProgressBar - Linear progress (with variants)
- CircularProgress - Circular/spinner progress
- Resizable - Resizable panel groups
- Collapsible - Expand/collapse sections
- TopBarButton - Top bar navigation buttons
All components follow consistent patterns:
Components use class-variance-authority for variants:
import { buttonVariants } from '@spacedrive/primitives';
// Use variants directly
<button className={buttonVariants({ variant: 'subtle', size: 'sm' })}>
Small Subtle
</button>All interactive components support ref forwarding:
import { useRef } from 'react';
import { Button } from '@spacedrive/primitives';
function MyComponent() {
const buttonRef = useRef<HTMLButtonElement>(null);
return <Button ref={buttonRef}>Click me</Button>;
}Components compose className with internal styles:
<Button className="w-full mt-4">
{/* Classes are merged: internal + "w-full mt-4" */}
</Button>- Accessible - Built on Radix UI primitives
- Composable - Small, focused components that compose
- Theme-agnostic - Uses semantic color classes
- No business logic - Purely presentational
- Type-safe - Full TypeScript support
Use Tailwind classes to override:
<Button
variant="default"
className="bg-purple-500 hover:bg-purple-600" {/* Override colors */}
>
Custom Button
</Button>Extend CVA variants:
import { cva } from 'class-variance-authority';
const myButtonVariants = cva(
'base-styles',
{
variants: {
size: {
xs: 'px-2 py-1 text-xs',
xl: 'px-6 py-3 text-lg',
}
}
}
);- Chrome/Edge 88+
- Firefox 78+
- Safari 14+
Requires CSS custom properties support.
MIT © Spacedrive