Component reference
Spacer
Separate groups of actions in a responsive app bar.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
App bar
The brand and the actions stay at opposite ends at every width.
Pimolu
Card footer
A spacer pushes the secondary action away from the primary one.
Divider rhythm
Fixed spacers separate label groups without extra margins.
Width adapts to the available space
"use client";
import {
Card,
CardHeader,
CardTitle,
CardDescription,
CardContent,
Flex,
Heading,
Spacer,
HStack,
Badge,
Button,
VStack,
Text,
Box
} from "@pimolu/react";
function Pill({ children, }: {
children: string;
}) {
return (
<Box padding={2} paddingX={3} background="muted">
<Text size="sm">
{children}
</Text>
</Box>
);
}
export function DemoExample() {
return (
<div
className="grid grid-cols-[repeat(auto-fit,minmax(min(100%,280px),1fr))] gap-6 min-w-0 items-start"
>
<Card>
<CardHeader>
<CardTitle>App bar</CardTitle>
<CardDescription>
The brand and the actions stay at opposite ends at every width.
</CardDescription>
</CardHeader>
<CardContent>
<Flex gap={3} align="center" wrap fullWidth>
<Heading level={3} size="md">Pimolu</Heading>
<Spacer />
<HStack gap={2} align="center">
<Badge variant="secondary">docs</Badge>
<Button size="sm" appearance="ghost">Sign in</Button>
<Button size="sm">Get started</Button>
</HStack>
</Flex>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Card footer</CardTitle>
<CardDescription>
A spacer pushes the secondary action away from the primary one.
</CardDescription>
</CardHeader>
<CardContent>
<VStack gap={4}>
<Text size="sm" tone="muted">
Changes are saved automatically when the dialog closes.
</Text>
<HStack gap={2} align="center">
<Button size="sm" appearance="ghost">Discard</Button>
<Spacer />
<Button size="sm" appearance="outline">Save draft</Button>
<Button size="sm">Publish</Button>
</HStack>
</VStack>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Divider rhythm</CardTitle>
<CardDescription>
Fixed spacers separate label groups without extra margins.
</CardDescription>
</CardHeader>
<CardContent>
<HStack gap={0} align="center" wrap>
<Pill>Profile</Pill>
<Spacer
size={4}
axis="horizontal"
style={{
height: 1,
background: "var(--pimolu-border)",
}}
/>
<Pill>Security</Pill>
<Spacer
size={4}
axis="horizontal"
style={{
height: 1,
background: "var(--pimolu-border)",
}}
/>
<Pill>Notifications</Pill>
</HStack>
</CardContent>
</Card>
</div>
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Flexible
Without size, the spacer absorbs the free space in a row or a column.
Fixed size
size uses the spacing scale and flex: 0 0 auto, so it never grows or shrinks.
Axis
horizontal sizes the inline axis, vertical the block axis, both (default) does both.
Usage
Use flexible space between groups and ordinary gap within related controls.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluSpacerProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
as | ElementType | undefined | `div` | Element rendered by the spacer. Defaults to `div`. |
size | PimoluSpacerSpace | undefined | — | Fixed size. Omit it for a flexible spacer (`flex: 1 1 auto`) that absorbs the free space in a Stack or Flex. |
axis | PimoluSpacerAxis | undefined | `both` | Axis occupied by a fixed spacer. Defaults to `both`. |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
children | ReactNode | — | Standard React/HTML attribute. |
onChange | ChangeEventHandler<HTMLElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLElement> | undefined | — | Standard React/HTML attribute. |
asElementType | undefinedDefault: `div`
Element rendered by the spacer. Defaults to `div`.
sizePimoluSpacerSpace | undefinedNo default extracted.
Fixed size. Omit it for a flexible spacer (`flex: 1 1 auto`) that absorbs the free space in a Stack or Flex.
axisPimoluSpacerAxis | undefinedDefault: `both`
Axis occupied by a fixed spacer. Defaults to `both`.
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
childrenReactNodeNo default extracted.
Standard React/HTML attribute.
onChangeChangeEventHandler<HTMLElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLElement> | undefinedNo default extracted.
Standard React/HTML attribute.
Accessibility
- Do not hide or push essential controls outside the viewport on small screens.