Tessina UI
Tessina UI
GitHubIntroduction
InstallationUsageTheming
Components
ButtonIconButtonLinkSpinnerBadgeAvatarStatusChipShortcutSkeletonSurfaceProgressMeterRating
LabelFieldFieldsetCheckboxRadioSwitchSliderSelectComboboxSearchTextareaNumberFieldDate PickerTime PickerOTP InputFile UploadCalendar
AlertBannerToastTooltip
TabsAccordionCollapsibleBreadcrumbPaginationStepperSegmentedControlButtonGroupToggleButtonToggleGroupToolbarNavigation MenuMenubarBottom NavSidebar
Split ButtonFABDropdown MenuContextMenuCommandPopoverHoverCard
ContainerStackFlexGridAspectRatioSpacerCardCarouselDividerScroll Area
Table
ChatBubblePromptInputCodeBlock
ModalAlertDialogDrawerAction SheetTop Header MobileTop Header DesktopEmptyStateForm
Contributing
ComponentsLayout Blocks

Flex

A low-level flexbox layout primitive that exposes the full flex API — four directions, three wrap modes, independent row and column gap, align-items, justify-content, align-content, inline mode, polymorphic render, and LTR/RTL. Ships with FlexItem for per-child grow, shrink, basis, order, and alignSelf control.

Playground

Installation

pnpm add @tessinaui/ui

Usage

import { Flex, FlexItem } from "@tessinaui/ui";
{/* Row layout */}
<Flex direction="row" gap="md" align="center">
  <Avatar src="/me.png" />
  <div className="flex flex-col">
    <p className="font-medium">Jane</p>
    <p className="text-muted-foreground">jane@example.com</p>
  </div>
</Flex>

{/* Column layout */}
<Flex direction="column" gap="sm">
  <h2>Title</h2>
  <p>Body</p>
  <button>Action</button>
</Flex>

{/* Wrapping with independent gaps */}
<Flex direction="row" wrap="wrap" columnGap="xl" rowGap="sm">
  {tags.map((t) => <Chip key={t}>{t}</Chip>)}
</Flex>

{/* Sidebar + main with FlexItem grow */}
<Flex direction="row" gap="md">
  <aside className="w-48">Sidebar</aside>
  <FlexItem grow>
    <main>Main content fills the remaining space</main>
  </FlexItem>
</Flex>

{/* Three columns with fractional basis */}
<Flex direction="row" gap="md">
  <FlexItem basis="1/4">Left</FlexItem>
  <FlexItem basis="2/4">Center</FlexItem>
  <FlexItem basis="1/4">Right</FlexItem>
</Flex>

{/* Reorder with order prop */}
<Flex direction="row" gap="sm">
  <FlexItem order="last">rendered last</FlexItem>
  <div>rendered first</div>
  <FlexItem order="first">rendered even earlier</FlexItem>
</Flex>

{/* Polymorphic */}
<Flex direction="row" gap="sm" render={<nav aria-label="Primary" />}>
  <a href="/">Home</a>
  <a href="/about">About</a>
</Flex>

{/* RTL */}
<Flex direction="row" dir="rtl" gap="sm">
  <span>أول</span>
  <span>ثاني</span>
</Flex>

Showcase

Direction

Unlike Stack, Flex exposes all four flex-direction values directly.

ValueCSS mapping
"row" (default)flex-row
"column"flex-col
"row-reverse"flex-row-reverse
"column-reverse"flex-col-reverse

Wrap

ValueCSS mapping
"nowrap" (default)flex-nowrap
"wrap"flex-wrap
"wrap-reverse"flex-wrap-reverse

Gap

Seven presets that map to Tailwind's spacing scale.

ValueTailwindpx
"none"gap-00
"xs"gap-14
"sm"gap-28
"md"gap-416
"lg"gap-624
"xl"gap-832
"2xl"gap-1248

For independent axis control use rowGap and columnGap — they accept the same seven values and override gap on their respective axis.

<Flex wrap="wrap" columnGap="xl" rowGap="sm">…</Flex>

Align (align-items)

Cross-axis alignment of children.

ValueCSS mapping
"start"items-start
"center"items-center
"end"items-end
"stretch" (default)items-stretch
"baseline"items-baseline

Justify (justify-content)

Main-axis distribution.

ValueCSS mapping
"start" (default)justify-start
"center"justify-center
"end"justify-end
"between"justify-between
"around"justify-around
"evenly"justify-evenly

Content (align-content)

Applies only when wrap is enabled and there are multiple rows on the cross axis.

ValueCSS mapping
"start"content-start
"center"content-center
"end"content-end
"between"content-between
"around"content-around
"evenly"content-evenly
"stretch"content-stretch
"baseline"content-baseline

Inline

inline={true} swaps flex for inline-flex so the container flows alongside surrounding text or other inline-level elements.

Polymorphic render

Preserve Flex styling while mounting semantic HTML.

<Flex direction="row" gap="md" render={<nav aria-label="Primary" />}>
  <a href="/">Home</a>
  <a href="/about">About</a>
</Flex>

<Flex render={<section />} direction="column" gap="lg">
  <h2>Settings</h2>
  <p>Adjust your preferences below.</p>
</Flex>

FlexItem

A helper for setting flex-child properties (flex-grow, flex-shrink, flex-basis, order, align-self) without reaching for Tailwind classes directly. FlexItem is optional — you can always apply grow, shrink-0, etc. inline on any child.

<Flex direction="row" gap="md">
  <aside className="w-48">Sidebar</aside>
  <FlexItem grow>
    <main>Main (grows to fill)</main>
  </FlexItem>
</Flex>

grow

ValueCSS
true / 1grow
false / 0grow-0
2, 3, 4, 5flex-grow: n

shrink

ValueCSS
true / 1shrink
false / 0shrink-0
2, 3, 4, 5flex-shrink: n

basis

Presets cover fractional layouts without arbitrary values.

"auto" · "full" · "0" · "1/2" · "1/3" · "2/3" · "1/4" · "2/4" · "3/4" · "1/5" · "2/5" · "3/5" · "4/5" · "1/6" · "5/6" · "1/12" through "11/12"

order

ValueCSS
"none"order-none
"first"order-first
"last"order-last
1 – 12order-n

alignSelf

"auto" · "start" · "center" · "end" · "stretch" · "baseline" → self-*

RTL

dir="rtl" is forwarded to the DOM node and flips the main axis of row directions. Column directions are unaffected by text direction.

Accessibility

  • Flex is a structural primitive — it applies no ARIA roles.
  • Use render to mount semantic HTML (<nav>, <ul>, <section>, <header>) when the grouping has meaning.
  • Reordering children with order or row-reverse/column-reverse separates visual order from DOM order. Keep DOM order logical — screen readers and keyboard navigation follow source order, not visual order.
  • inline does not remove any semantics — the element remains a <div> (or whatever render provides).

When to use Flex vs. Stack

Both are flex wrappers. Pick based on how much of the flex API you actually need.

Use Stack when…Use Flex when…
You want a single-axis layout with sensible defaultsYou need the full flexbox API
Direction should flip via a single propYou want explicit row-reverse / column-reverse
Gap presets are enoughYou need independent rowGap and columnGap
Children size themselves naturallyYou need grow / shrink / basis / order on children

For many apps Stack is the right pick. Reach for Flex when you're building a layout that can't be expressed through Stack's opinionated API.

API Reference

Flex Props

PropTypeDefaultDescription
direction"row" | "column" | "row-reverse" | "column-reverse""row"flex-direction
wrap"nowrap" | "wrap" | "wrap-reverse""nowrap"flex-wrap
gap"none" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl"—Shorthand for both row and column gap
rowGapSame as gap—Vertical gap (overrides gap on that axis)
columnGapSame as gap—Horizontal gap (overrides gap on that axis)
align"start" | "center" | "end" | "stretch" | "baseline""stretch"align-items
justify"start" | "center" | "end" | "between" | "around" | "evenly""start"justify-content
content"start" | "center" | "end" | "between" | "around" | "evenly" | "stretch" | "baseline"—align-content — only relevant with wrap
inlinebooleanfalseUses inline-flex instead of flex
renderReactElement—Polymorphic target — clone this element and apply Flex styles
dir"ltr" | "rtl"—Text direction forwarded to the DOM node
classNamestring—Extra classes on the root element

FlexItem Props

PropTypeDefaultDescription
growboolean | 0 | 1 | 2 | 3 | 4 | 5—flex-grow
shrinkboolean | 0 | 1 | 2 | 3 | 4 | 5—flex-shrink
basisFraction preset (see table above)—flex-basis
order"none" | "first" | "last" | 1..12—order
alignSelf"auto" | "start" | "center" | "end" | "stretch" | "baseline"—align-self
renderReactElement—Polymorphic target
dir"ltr" | "rtl"—Text direction forwarded to the DOM node
classNamestring—Extra classes on the root element

Notes

  • No intrinsic padding. Flex only controls layout — add padding, borders, background via className.
  • No SSR caveats. Flex is a pure wrapper with no hooks; safe to render server-side.
  • content is a prop, not an HTML attribute. React's native content HTML attribute (meta-tag-only) is omitted from Flex's props so the CVA variant takes precedence.
  • Arbitrary values. If a fraction you need isn't in the basis preset list, drop to className="basis-[...]" — FlexItem's class output is merged after its props.

Stack

A flex-based layout primitive for arranging items in a row or column. Configurable direction, gap, alignment, justification, wrapping, reversal, dividers, inline display, polymorphic rendering, and LTR/RTL support. Ships with HStack and VStack convenience wrappers.

Grid

A CSS-grid layout primitive with static and responsive column counts, gap presets, flow control, and per-cell placement via GridItem. Polymorphic render, RTL, and no hard-coded tokens.

On this page

PlaygroundInstallationUsageShowcaseDirectionWrapGapAlign (align-items)Justify (justify-content)Content (align-content)InlinePolymorphic renderFlexItemgrowshrinkbasisorderalignSelfRTLAccessibilityWhen to use Flex vs. StackAPI ReferenceFlex PropsFlexItem PropsNotes