xonecas.io
70160
Ce

cel-tui / files

cel-tui / packages / components / src / spacer.ts

621 bytes
1import { VStack } from "@cel-tui/core";
2import type { ContainerNode } from "@cel-tui/types";
3
4/**
5 * Flexible spacer that fills available space along the parent's main axis.
6 *
7 * Equivalent to an empty `VStack({ flex: 1 }, [])`. Use inside an HStack
8 * to push siblings apart, or inside a VStack for vertical spacing.
9 *
10 * @returns A flex container node that expands to fill remaining space.
11 *
12 * @example
13 * // Push items to opposite ends of a row
14 * HStack({ height: 1 }, [
15 *   Text("left"),
16 *   Spacer(),
17 *   Text("right"),
18 * ])
19 */
20export function Spacer(): ContainerNode {
21  return VStack({ flex: 1 }, []);
22}