Primitives
Spacer
Explicit whitespace from the shared scale — fixed by size, or grow to push items apart in a flex run.
Motionnone — layout primitive
Install
Install Kineto and follow the theme setup once in your app.
bash
npm install kinetotsx
import { Spacer } from "kineto/spacer";Preview
Above
48px gap below — set by size="xl"
tsx
import * as React from "react";
import { cn } from "@/lib/cn";
import { spacerXClass, spacerYClass, type Gap } from "@/lib/gap";
export interface SpacerProps extends React.HTMLAttributes<HTMLDivElement> {
/** Fixed size from the shared gap scale (ignored when `grow`). */
size?: Gap;
/** Which axis the space occupies. */
axis?: "vertical" | "horizontal";
/** Grow to fill available space in a flex parent (a push-apart spacer) instead of a fixed size. */
grow?: boolean;
}
/**
* Explicit, intentional whitespace using the shared scale — instead of a stray `mt-*` on the next
* element. Fixed by default (`size`), or set `grow` to absorb free space in a flex row/column
* (e.g. push a trailing action to the end of a toolbar).
*/
const Spacer = React.forwardRef<HTMLDivElement, SpacerProps>(
({ className, size = "md", axis = "vertical", grow = false, ...props }, ref) => (
<div
ref={ref}
aria-hidden="true"
className={cn(
"shrink-0",
grow
? "flex-1 self-stretch"
: axis === "horizontal"
? spacerXClass[size]
: spacerYClass[size],
className
)}
{...props}
/>
)
);
Spacer.displayName = "Spacer";
export { Spacer };src/components/ui/spacer.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| size | "none" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "md" | Fixed size from the shared scale (ignored when grow). |
| axis | "vertical" | "horizontal" | "vertical" | Which axis the space occupies. |
| grow | boolean | false | Fill available space in a flex parent instead of a fixed size. |