# HStack

A horizontal Stack convenience primitive with logical-axis alignment.

`HStack` is Stack with a fixed horizontal direction. It adds `hAlign` and `vAlign` aliases so alignment can be described in visual axes.

```tsx
import { Button, HStack, Stack, Text } from "@zentara-co/zenos-ui";

function HStackExample() {
  return (
    <HStack
      hAlign="between"
      vAlign="center"
      gap="3"
      className="w-full rounded-xl border border-border bg-background-neutral-card p-4"
    >
      <Stack gap="1">
        <Text weight="bold">Workspace</Text>
        <Text size="s" color="subtle">
          24 members
        </Text>
      </Stack>
      <Button size="sm">Invite member</Button>
    </HStack>
  );
}
```

## Import

```tsx
import { HStack } from "@zentara-co/zenos-ui";
```

## Logical alignment

`hAlign` distributes children horizontally and maps to Stack's `justify`. `vAlign` aligns children vertically and maps to Stack's `align`.

```tsx
import { Badge, HStack, Stack } from "@zentara-co/zenos-ui";

function HStackAlignmentExample() {
  return (
    <Stack gap="4" className="w-full">
      {(["start", "center", "between"] as const).map((hAlign) => (
        <HStack
          key={hAlign}
          hAlign={hAlign}
          vAlign="center"
          gap="2"
          className="min-h-20 rounded-xl border border-border bg-background-neutral-card p-3"
        >
          <Badge>{hAlign}</Badge>
          <Badge variant="default" color="information">
            Item
          </Badge>
        </HStack>
      ))}
    </Stack>
  );
}
```

The shared `align` and `justify` props remain available and take precedence over the aliases when both are supplied. HStack also supports Stack's responsive gap, wrapping, padding, size constraints, scrolling, polymorphism, and native props.

Use Cluster when the main requirement is a wrapping row of related items. Use HStack when distribution, sizing, or the complete Stack API matters.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | ElementType | div | Rendered semantic element. |
| hAlign | Responsive<Justify> | — | Horizontal distribution. |
| vAlign | Responsive<Align> | — | Vertical alignment. |
| gap | Responsive<Spacing> | 4 | Space between children. |
| wrap | Responsive<boolean \| FlexWrap> | false | Wrapping behavior. |
| shared Stack props | padding*, size constraints, isScrollable | — | HStack supports Stack spacing, sizing, scrolling, and native props. |
| native props | React.HTMLAttributes<HTMLElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

HStack does not add semantics or reorder children. Choose `as` for the content and keep the source order meaningful when using `hAlign="end"`, `between`, or `evenly`.

Source: https://zenos-ui.pages.dev/layout/h-stack/