# Row

> A fundamental layout component that arranges its children in a horizontal line. It is built on the flexbox model and is used to create columns.

Source: https://vaneui.com/docs/layout-components/row

Import: `import { Row, Badge, Button, Card, Col, Text, Title } from "@vaneui/ui"`

Row suits content that sits side by side at its natural width: a toolbar, a set of tags, an icon beside its label. When the children should share equal column widths instead, a [Grid](/docs/layout-components/grid) component such as Grid3 sizes them. For a vertical group, use [Col](/docs/layout-components/col), or [Stack](/docs/layout-components/stack) when the group also needs its own padding.

## Basic usage

A horizontal flex container. `Row` defaults to `gap`, `itemsCenter`, `noPadding`, `noBorder`, `noInsetRing`, `outline`, and `sharp`: you don't need to pass these explicitly. Pass `href` to render `Row` as `<a>` instead of `<div>`. A focus-visible outline auto-enables when `href` is set.

```tsx demo
<Row>
  <div className="p-4 bg-gray-100 rounded">Item 1</div>
  <div className="p-4 bg-gray-100 rounded">Item 2</div>
  <div className="p-4 bg-gray-100 rounded">Item 3</div>
</Row>
```

## Spacing

Use size props (`xs`, `sm`, `md`, `lg`, `xl`) to control the gap amount, or `noGap` to disable. `gapXs` to `gapXl` fix the gap at one step for every size and screen width: `<Row gapSm>` always has a 12px gap. [Common Props](/docs/reference/common-props) lists each step.

```tsx demo
<Col>
  <Text fontSemibold>xs</Text>
  <Row xs>
    <div className="p-3 bg-gray-100 rounded">Item 1</div>
    <div className="p-3 bg-gray-100 rounded">Item 2</div>
    <div className="p-3 bg-gray-100 rounded">Item 3</div>
  </Row>
  <Text fontSemibold>sm</Text>
  <Row sm>
    <div className="p-3 bg-gray-100 rounded">Item 1</div>
    <div className="p-3 bg-gray-100 rounded">Item 2</div>
    <div className="p-3 bg-gray-100 rounded">Item 3</div>
  </Row>
  <Text fontSemibold>md (default)</Text>
  <Row>
    <div className="p-3 bg-gray-100 rounded">Item 1</div>
    <div className="p-3 bg-gray-100 rounded">Item 2</div>
    <div className="p-3 bg-gray-100 rounded">Item 3</div>
  </Row>
  <Text fontSemibold>lg</Text>
  <Row lg>
    <div className="p-3 bg-gray-100 rounded">Item 1</div>
    <div className="p-3 bg-gray-100 rounded">Item 2</div>
    <div className="p-3 bg-gray-100 rounded">Item 3</div>
  </Row>
  <Text fontSemibold>xl</Text>
  <Row xl>
    <div className="p-3 bg-gray-100 rounded">Item 1</div>
    <div className="p-3 bg-gray-100 rounded">Item 2</div>
    <div className="p-3 bg-gray-100 rounded">Item 3</div>
  </Row>
  <Text fontSemibold>noGap</Text>
  <Row noGap>
    <div className="p-3 bg-gray-100 rounded">Item 1</div>
    <div className="p-3 bg-gray-100 rounded">Item 2</div>
    <div className="p-3 bg-gray-100 rounded">Item 3</div>
  </Row>
</Col>
```

## Justify (main axis)

Control horizontal distribution with `justifyStart`, `justifyEnd`, `justifyCenter`, `justifyBetween`, `justifyAround`, or `justifyEvenly`.

```tsx demo
<Col>
  <Text fontSemibold>justifyStart</Text>
  <Row justifyStart className="border-2 border-dashed border-gray-300 p-2">
    <div className="p-2 bg-gray-100 rounded">A</div>
    <div className="p-2 bg-gray-100 rounded">B</div>
    <div className="p-2 bg-gray-100 rounded">C</div>
  </Row>
  <Text fontSemibold>justifyEnd</Text>
  <Row justifyEnd className="border-2 border-dashed border-gray-300 p-2">
    <div className="p-2 bg-gray-100 rounded">A</div>
    <div className="p-2 bg-gray-100 rounded">B</div>
    <div className="p-2 bg-gray-100 rounded">C</div>
  </Row>
  <Text fontSemibold>justifyCenter</Text>
  <Row justifyCenter className="border-2 border-dashed border-gray-300 p-2">
    <div className="p-2 bg-gray-100 rounded">A</div>
    <div className="p-2 bg-gray-100 rounded">B</div>
    <div className="p-2 bg-gray-100 rounded">C</div>
  </Row>
  <Text fontSemibold>justifyBetween</Text>
  <Row justifyBetween className="border-2 border-dashed border-gray-300 p-2">
    <div className="p-2 bg-gray-100 rounded">A</div>
    <div className="p-2 bg-gray-100 rounded">B</div>
    <div className="p-2 bg-gray-100 rounded">C</div>
  </Row>
  <Text fontSemibold>justifyAround</Text>
  <Row justifyAround className="border-2 border-dashed border-gray-300 p-2">
    <div className="p-2 bg-gray-100 rounded">A</div>
    <div className="p-2 bg-gray-100 rounded">B</div>
    <div className="p-2 bg-gray-100 rounded">C</div>
  </Row>
  <Text fontSemibold>justifyEvenly</Text>
  <Row justifyEvenly className="border-2 border-dashed border-gray-300 p-2">
    <div className="p-2 bg-gray-100 rounded">A</div>
    <div className="p-2 bg-gray-100 rounded">B</div>
    <div className="p-2 bg-gray-100 rounded">C</div>
  </Row>
</Col>
```

## Items (cross axis)

Control vertical alignment with `itemsStart`, `itemsEnd`, `itemsCenter` (default), `itemsBaseline`, or `itemsStretch`.

```tsx demo
<Col>
  <Text fontSemibold>itemsStart</Text>
  <Row itemsStart className="border-2 border-dashed border-gray-300 p-2 h-24">
    <div className="p-2 bg-gray-100 rounded">Small</div>
    <div className="p-6 bg-gray-100 rounded">Tall</div>
    <div className="p-2 bg-gray-100 rounded">Small</div>
  </Row>
  <Text fontSemibold>itemsEnd</Text>
  <Row itemsEnd className="border-2 border-dashed border-gray-300 p-2 h-24">
    <div className="p-2 bg-gray-100 rounded">Small</div>
    <div className="p-6 bg-gray-100 rounded">Tall</div>
    <div className="p-2 bg-gray-100 rounded">Small</div>
  </Row>
  <Text fontSemibold>itemsCenter (default)</Text>
  <Row className="border-2 border-dashed border-gray-300 p-2 h-24">
    <div className="p-2 bg-gray-100 rounded">Small</div>
    <div className="p-6 bg-gray-100 rounded">Tall</div>
    <div className="p-2 bg-gray-100 rounded">Small</div>
  </Row>
  <Text fontSemibold>itemsBaseline</Text>
  <Row itemsBaseline className="border-2 border-dashed border-gray-300 p-2 h-24">
    <Text sm>Small text</Text>
    <Text xl>Large text</Text>
    <Text>Default</Text>
  </Row>
  <Text fontSemibold>itemsStretch</Text>
  <Row itemsStretch className="border-2 border-dashed border-gray-300 p-2 h-24">
    <div className="p-2 bg-gray-100 rounded">A</div>
    <div className="p-2 bg-gray-100 rounded">B</div>
    <div className="p-2 bg-gray-100 rounded">C</div>
  </Row>
</Col>
```

## Wrap

Use `flexWrap` to allow items to wrap to the next line when they overflow.

```tsx demo
<Row flexWrap className="max-w-md border-2 border-dashed border-gray-300 p-2">
  <div className="p-4 bg-gray-100 rounded">Item 1</div>
  <div className="p-4 bg-gray-100 rounded">Item 2</div>
  <div className="p-4 bg-gray-100 rounded">Item 3</div>
  <div className="p-4 bg-gray-100 rounded">Item 4</div>
  <div className="p-4 bg-gray-100 rounded">Item 5</div>
</Row>
```

## Reverse order

Use `rowReverse` to reverse the visual order of children.

```tsx demo
<Row rowReverse className="border-2 border-dashed border-gray-300 p-2">
  <div className="p-4 bg-gray-100 rounded">First in DOM</div>
  <div className="p-4 bg-gray-100 rounded">Second</div>
  <div className="p-4 bg-gray-100 rounded">Last in DOM</div>
</Row>
```

## Responsive layout

Use `mobileStack` to stack on mobile, or `tabletStack` to stack on tablet and below.

```tsx demo
<Col>
  <Text fontSemibold>tabletStack (stacks below 1024px)</Text>
  <Row tabletStack>
    <Col flex1 className="p-4 bg-primary-100 rounded">
      <Text fontSemibold>Column 1</Text>
      <Text>Horizontal on desktop, stacked on tablet and below.</Text>
    </Col>
    <Col flex1 className="p-4 bg-primary-100 rounded">
      <Text fontSemibold>Column 2</Text>
      <Text>Resize to see the responsive behavior.</Text>
    </Col>
  </Row>
  <Text fontSemibold>mobileStack (stacks below 768px)</Text>
  <Row mobileStack>
    <Col flex1 className="p-4 bg-primary-100 rounded">
      <Text fontSemibold>Column 1</Text>
      <Text>Horizontal until mobile.</Text>
    </Col>
    <Col flex1 className="p-4 bg-primary-100 rounded">
      <Text fontSemibold>Column 2</Text>
      <Text>Stacks only on narrow viewports.</Text>
    </Col>
  </Row>
</Col>
```

Breakpoints are desktop-first and exclusive: `mobileStack` collapses to a column below 768px, `tabletStack` below 1024px, `desktopStack` below 1280px. The boundary pixel itself stays in the row layout. Combining several stack props resolves to the widest, so `mobileStack tabletStack` stacks below 1024px. `*Stack` only affects row-direction components: it emits `flex-col`, so it is a no-op on `Col`, `Stack`, `Container`, and `Section`, which are already columns.

A stacked `Row` keeps its default `itemsCenter`, so stacked children shrink to content width. Add `itemsStretch` for full-width stacked cards.

## Variants

Use `filled` or `outline` with appearance props for styled rows. Row uses `sharp` (no border-radius) by default: pair with `rounded` or `pill` for curved corners.

```tsx demo
<Col>
  <Row filled primary padding rounded>
    <div className="p-4 bg-white/80 rounded">Filled Primary</div>
    <div className="p-4 bg-white/80 rounded">Item 2</div>
  </Row>
  <Row border success padding rounded>
    <div className="p-4 rounded">Outline Success</div>
    <div className="p-4 rounded">Item 2</div>
  </Row>
</Col>
```

## Text alignment

Use `textCenter`, `textLeft`, `textRight`, or `textJustify` to control text alignment within the row.

```tsx demo
<Col>
  <Row textLeft className="border-2 border-dashed border-gray-300 p-4">
    <Text>Left aligned content in a row.</Text>
  </Row>
  <Row textCenter className="border-2 border-dashed border-gray-300 p-4">
    <Text>Center aligned content in a row.</Text>
  </Row>
  <Row textRight className="border-2 border-dashed border-gray-300 p-4">
    <Text>Right aligned content in a row.</Text>
  </Row>
</Col>
```

## Inside a Card

Row composes naturally inside a Card to lay out header actions, button groups, or any horizontal cluster.

```tsx demo
<Card>
  <Row justifyBetween>
    <Title>Settings</Title>
    <Badge success>Active</Badge>
  </Row>
  <Text>Configure your preferences below.</Text>
  <Row justifyEnd>
    <Button secondary>Cancel</Button>
    <Button filled>Save</Button>
  </Row>
</Card>
```

## As Link

Add `href` to render the Row as an `<a>` tag, useful for clickable list rows. A keyboard focus-visible outline auto-renders so the link is reachable via Tab; opt out with `noFocusVisible`.

```tsx demo
<Col>
  <Row href="#as-link" justifyBetween padding border rounded>
    <Text fontSemibold>Inbox</Text>
    <Badge primary filled>12</Badge>
  </Row>
  <Row href="#as-link" justifyBetween padding border rounded>
    <Text fontSemibold>Drafts</Text>
    <Badge secondary>3</Badge>
  </Row>
  <Row href="https://github.com" target="_blank" rel="noopener noreferrer" justifyBetween padding border rounded>
    <Text fontSemibold>GitHub</Text>
    <Text sm secondary>External</Text>
  </Row>
</Col>
```

## Next.js Link integration

Use the `tag` prop to render the Row as a Next.js `Link` for client-side navigation.

```tsx
import Link from 'next/link';
import { Row, Text, Badge } from '@vaneui/ui';

<Row href="/inbox" tag={Link} justifyBetween padding border rounded>
  <Text fontSemibold>Inbox</Text>
  <Badge primary filled>12</Badge>
</Row>
```

## Frequently asked questions

### Why does `mobileStack` do nothing in my app?

With your own Tailwind build, the responsive props need the `@vaneui/ui/tokens` import. It registers the `mobile`, `tablet` and `desktop` breakpoints, and without it Tailwind emits no CSS for `mobileStack`, `tabletStack` or the hide and show props, with no build error. Add it next to `@vaneui/ui/vars` as shown in [CSS setup](/docs/getting-started/installation#css-setup). The prebuilt `@vaneui/ui/css` already contains it.

### How do I push one item to the end of a Row?

Give the item before it `flex1`, so that item takes the free width and everything after it moves to the end edge. For two groups, such as a title on the left and buttons on the right, use `justifyBetween` on a Row with two children, and wrap each group in its own `Row`. `justifyEnd` moves every child to the end.

### Why do the items in my Row overflow on a phone?

A Row keeps its children on one line, so when they need more width than the screen has, they run past its edge. Add `flexWrap` to let them wrap onto a new line, or `mobileStack` to stack them below 768px. A long word or URL in a child can still overflow; `breakWords` on that `Text` lets it break.

## Props

| Prop | Category | Default | Description |
| --- | --- | --- | --- |
| `primary` | Appearance |  | Primary color appearance (gray) |
| `accent` | Appearance |  | Accent color appearance (rose) |
| `secondary` | Appearance |  | Secondary color appearance (gray) |
| `tertiary` | Appearance |  | Tertiary color appearance |
| `success` | Appearance |  | Success color appearance (green) |
| `danger` | Appearance |  | Danger color appearance (red) |
| `warning` | Appearance |  | Warning color appearance (amber) |
| `info` | Appearance |  | Info color appearance (cyan) |
| `inheritAppearance` | Appearance |  | Inherit appearance from parent — suppresses own data-appearance/data-variant, uses parent's CSS variables |
| `aspectSquare` | Aspect |  | Square box (aspect-ratio: 1 / 1) |
| `aspectVideo` | Aspect |  | Video box (aspect-ratio: 16 / 9) |
| `aspectAuto` | Aspect |  | The content's own ratio (aspect-ratio: auto) |
| `desktopStack` | Breakpoint |  | Stack into a column at desktop width and below (max-desktop: 80rem) |
| `tabletStack` | Breakpoint |  | Stack into a column at tablet width and below (max-tablet: 64rem) |
| `mobileStack` | Breakpoint |  | Stack into a column at mobile width and below (max-mobile: 48rem) |
| `flex1` | Flex |  | Take up remaining space (= `flex-1`, i.e. `flex: 1 1 0%`) |
| `flexAuto` | Flex |  | Grow but respect intrinsic size (= `flex-auto`, i.e. `flex: 1 1 auto`) |
| `flexNone` | Flex |  | Don't grow and don't shrink (= `flex-none`, i.e. `flex: none`) |
| `margin` | Margin |  | Enable margin on all sides |
| `marginX` | Margin |  | Enable only horizontal (inline) margin |
| `marginY` | Margin |  | Enable only vertical (block) margin |
| `marginT` | Margin |  | Enable only top margin |
| `marginB` | Margin |  | Enable only bottom margin |
| `noMargin` | Margin |  | Disable margin (reset to 0) |
| `padding` | Padding |  | Enable internal padding |
| `paddingX` | Padding |  | Enable only horizontal padding |
| `paddingY` | Padding |  | Enable only vertical padding |
| `noPadding` | Padding | yes | Disable internal padding |
| `pill` | Shape |  | Fully rounded corners (circular) |
| `sharp` | Shape | yes | No rounded corners (square) |
| `rounded` | Shape |  | Medium rounded corners (default) |
| `noShrink` | Shrink |  | Prevent the flex item from shrinking below its content size (= `shrink-0`) |
| `xs` | Size |  | Extra small size |
| `sm` | Size |  | Small size |
| `md` | Size | yes | Medium size (default) |
| `lg` | Size |  | Large size |
| `xl` | Size |  | Extra large size |
| `skeleton` | Skeleton |  | Show the component as a loading placeholder in its own size and shape. On a container, every component inside it becomes a placeholder too |
| `strongBorder` | Strong Border |  | Paint the border in the appearance's strong color instead of its soft one |
| `textLeft` | Text Align |  | Align text to left (physical side, does not flip under RTL) |
| `textCenter` | Text Align |  | Align text to center |
| `textRight` | Text Align |  | Align text to right (physical side, does not flip under RTL) |
| `textJustify` | Text Align |  | Justify text |
| `textStart` | Text Align |  | Align text to the reading-direction start (left in LTR, right in RTL) |
| `textEnd` | Text Align |  | Align text to the reading-direction end (right in LTR, left in RTL) |
| `filled` | Variant |  | Filled variant - solid background with contrasting text color |
| `outline` | Variant | yes | Outline variant - transparent background with border and colored text (default) |
| `ghost` | Variant |  | Ghost variant - transparent background, no border, appearance-colored text, tinted hover background |

Layout and utility props (Border, Display, Flex Direction, Focus Visible, Gap, Height, Hide, Items, Justify, Overflow, Pointer Events, Position, Responsive Sizing, Responsive Width, Ring, Shadow, Show, Transparent, Whitespace, Width, Wrap) are listed on [Common Props](https://vaneui.com/docs/reference/common-props.md).
