# Stack Item

Controls growth, shrinkage, basis, and self-alignment inside Stack.

`StackItem` adjusts one child within Stack, HStack, or VStack. Use it only when that child needs growth, shrinkage, a tokenized basis, or different cross-axis alignment.

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

function StackItemExample() {
  return (
    <Stack
      direction="row"
      gap="3"
      align="stretch"
      className="w-full rounded-xl border border-border bg-background-neutral-card p-3"
    >
      <StackItem basis="xs" shrink={false}>
        <Center className="h-full rounded-lg border border-border-default bg-background-neutral-default p-3">
          <Text size="s">Fixed basis</Text>
        </Center>
      </StackItem>
      <StackItem grow>
        <Center className="h-full rounded-lg border border-border-default bg-background-neutral-default p-3">
          <Text size="s">Grows to fill</Text>
        </Center>
      </StackItem>
      <StackItem alignSelf="center">
        <Button size="sm">Action</Button>
      </StackItem>
    </Stack>
  );
}
```

## Import

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

## Flex sizing

`grow` defaults to false, while `shrink` defaults to true. `basis` sets the initial main-axis size from the shared size tokens.

```tsx
<Stack direction="row">
  <StackItem basis="xs" shrink={false}>
    Navigation
  </StackItem>
  <StackItem grow>Flexible content</StackItem>
  <StackItem>Actions</StackItem>
</Stack>
```

Use `alignSelf` when one item must override the parent's cross-axis alignment. Its values are `start`, `center`, `end`, `stretch`, and `baseline`.

## Semantics

StackItem is polymorphic and retains native props and refs. When Stack is a list, render each item as `li`.

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

function StackItemSemanticExample() {
  return (
    <Stack as="ul" gap="2" className="w-full max-w-lg list-none">
      {["Create workspace", "Invite members", "Run first scan"].map((item, index) => (
        <StackItem
          key={item}
          as="li"
          grow={index === 1}
          className="rounded-lg border border-border bg-background-neutral-card p-3"
        >
          <Text>
            {index + 1}. {item}
          </Text>
        </StackItem>
      ))}
    </Stack>
  );
}
```

StackItem does not need to wrap every Stack child. Plain elements participate in flex layout normally.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| as | ElementType | div | Rendered semantic element. |
| grow | boolean | false | Allows the item to grow. |
| shrink | boolean | true | Allows the item to shrink. |
| basis | SizeToken | — | Initial main-axis size. |
| alignSelf | AlignSelf | — | Overrides cross-axis alignment. |
| 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

Growth, basis, and alignment do not change semantics. Choose `as` to match the parent structure, and do not use flex sizing to produce a visual order that conflicts with reading or focus order.

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