Get Started
Components
- Accordion
- Alert Dialog
- Alert
- Aspect Ratio
- Avatar
- Badge
- Breadcrumb
- Button Group
- Button
- Card
- Carousel
- Checkbox
- Collapsible
- Combobox
- Command
- Container
- Context Menu
- Data Table
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Flex
- Form
- Grid
- Hero Button
- Hover Card
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Menubar
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Responsive
- Scroll Area
- Segmented Control
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spacer
- Spinner
- Squircle
- Switch
- Table
- Tabs
- Textarea
- Theme Toggle
- Toggle Group
- Toggle
- Tooltip
- Typography
- Unicorn Wrapper
Animations
- Background Image Parallax
- Card Swipe Carousel
- Cards Parallax
- Parallax Scroll
- Perspective Carousel
- Perspective Section Transition
- Scroll Expand
- Scroll Fade
- Scroll Scale
- Slide Down
- Slide Up
- Smooth Parallax Scroll
- Smooth Scroll
- Sticky Footer
- Text Along Path
- Text Gradient Opacity
- Text Parallax
- Transforms 3d
- Zoom Parallax
import { Spacer } from "@/components/ui/spacer"
export function SpacerDemo() {
return (
<div className="flex w-full max-w-md flex-col">
<div className="bg-card border-border text-foreground flex h-12 w-full items-center justify-center rounded-md border font-medium shadow-sm">
Box 1
</div>
<Spacer size="md" />
<div className="bg-card border-border text-foreground flex h-12 w-full items-center justify-center rounded-md border font-medium shadow-sm">
Box 2
</div>
<Spacer size="lg" />
<div className="bg-card border-border text-foreground flex h-12 w-full items-center justify-center rounded-md border font-medium shadow-sm">
Box 3
</div>
</div>
)
}
Installation
pnpm dlx pitsi@latest add spacer
Usage
import { Spacer } from "@/components/ui/spacer"<div className="flex flex-col">
<div>First element</div>
<Spacer size="md" />
<div>Second element</div>
</div>Examples
Vertical Spacing
import { Spacer } from "@/components/ui/spacer"
export function SpacerDemo() {
return (
<div className="flex w-full max-w-md flex-col">
<div className="bg-card border-border text-foreground flex h-12 w-full items-center justify-center rounded-md border font-medium shadow-sm">
Box 1
</div>
<Spacer size="md" />
<div className="bg-card border-border text-foreground flex h-12 w-full items-center justify-center rounded-md border font-medium shadow-sm">
Box 2
</div>
<Spacer size="lg" />
<div className="bg-card border-border text-foreground flex h-12 w-full items-center justify-center rounded-md border font-medium shadow-sm">
Box 3
</div>
</div>
)
}
Horizontal Spacing
<div className="flex flex-row">
<div>First</div>
<Spacer size="md" axis="horizontal" />
<div>Second</div>
</div>Size Variants
import { Spacer } from "@/components/ui/spacer"
export function SpacerSizes() {
const sizes = ["xxs", "xs", "sm", "md", "lg", "xl", "2xl", "3xl"] as const
return (
<div className="space-y-4">
{sizes.map((size) => (
<div key={size} className="flex items-center gap-4">
<span className="text-muted-foreground w-12 text-sm">{size}</span>
<div className="bg-foreground h-2 w-2 rounded-full" />
<Spacer size={size} axis="horizontal" />
<div className="bg-foreground h-2 w-2 rounded-full" />
</div>
))}
</div>
)
}
Props
Spacer
| Prop | Type | Default | Description |
|---|---|---|---|
size | "xxs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl" | "6xl" | "7xl" | "8xl" | "9xl" | "md" | The size of the spacer |
axis | "vertical" | "horizontal" | "vertical" | The direction of the spacer |
asChild | boolean | false | Render as a child element using Radix UI Slot |