Inline

Children in a row with even space between them, wrapping when they don't fit.

The row to Stack’s column: a toolbar, a title with its badge, a pair of buttons. Children are centered across the row and wrap onto more rows when they don’t fit; justify="between" pushes them to the ends.

Preview
basic.tsx
import { Button } from "~/components/ui/button"
import { Inline } from "~/components/ui/inline"
import { Text } from "~/components/ui/text"

export default function Example() {
  return (
    <Inline gap="md" justify="between" className="w-full max-w-md">
      <Inline gap="sm">
        <Text render={<span />} size="sm" weight="medium">
          Edition 412
        </Text>
        <Text render={<span />} size="sm" tone="muted">
          Draft
        </Text>
      </Inline>
      <Inline gap="xs">
        <Button variant="ghost" size="sm">
          Discard
        </Button>
        <Button size="sm">Publish</Button>
      </Inline>
    </Inline>
  )
}

Dependencies

What it's built from and what's built from it in Base, read from the imports in its source.

UsesStackprimitive
Used byNothing yet.
Packages @ui-sdk/core@0.1.0-beta.20@ui-sdk/react@0.1.0-beta.20tailwind-variants@4.1.0

Installation

Set the project up for Base once first, as Getting started shows. Then add it with the CLI, or by hand.

With the CLI

terminal
npx shadcn@latest add https://design.zepez.dev/r/base/inline.json

Manually

Install its packages:

terminal
npm install @ui-sdk/core@0.1.0-beta.20 @ui-sdk/react@0.1.0-beta.20 tailwind-variants@4.1.0

Add the components it uses first, listed under Dependencies.

Then copy the source:

components/ui/inline.tsx
import { renderElement, type RenderProp } from "@ui-sdk/react/primitive"
import type * as React from "react"
import { tv, type VariantProps } from "tailwind-variants"

import { gaps } from "~/components/ui/stack"
import { cn } from "~/lib/utils"

const inlineVariants = tv({
  base: "flex min-w-0 flex-row",
  variants: {
    gap: gaps,
    align: {
      start: "items-start",
      center: "items-center",
      end: "items-end",
      baseline: "items-baseline",
      stretch: "items-stretch",
    },
    justify: {
      start: "justify-start",
      center: "justify-center",
      end: "justify-end",
      between: "justify-between",
    },
    wrap: {
      true: "flex-wrap",
      false: "flex-nowrap",
    },
  },
  defaultVariants: { gap: "sm", align: "center", justify: "start", wrap: true },
})

type InlineVariants = VariantProps<typeof inlineVariants>

type InlineProps = React.ComponentProps<"div"> & {
  /** The space between children, a step on the spacing scale. */
  gap?: NonNullable<InlineVariants["gap"]>
  /** How children line up across the row. Centered unless you say otherwise. */
  align?: NonNullable<InlineVariants["align"]>
  /** Where children sit along the row; `between` pushes them to the ends. */
  justify?: NonNullable<InlineVariants["justify"]>
  /** Whether children wrap onto more rows when they don't fit. They do unless you say otherwise. */
  wrap?: boolean
  /** The element to render instead of a `<div>`, like `<ul />` or `<nav />`. */
  render?: RenderProp
}

/** Children in a row with even space between them, wrapping when they don't fit. */
function Inline({ gap, align, justify, wrap, render, className, ...props }: InlineProps) {
  return renderElement(
    "div",
    {
      "data-slot": "inline",
      className: cn(inlineVariants({ gap, align, justify, wrap }), className),
      ...props,
    },
    render,
  )
}

export { Inline, inlineVariants }
export type { InlineProps }

API reference

Generated from Base's types. Props marked ours are added here; the rest come from the ui-sdk part it wraps. Every part also accepts its element's native attributes.

Inline

Children in a row with even space between them, wrapping when they don't fit.

alignours

How children line up across the row. Centered unless you say otherwise.

Type NonNullable<"center" | "start" | "end" | "baseline" | "stretch">

gapours

The space between children, a step on the spacing scale.

Type NonNullable<"xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "none" | "3xs" | "2xs" | "4xl">

justifyours

Where children sit along the row; between pushes them to the ends.

Type NonNullable<"center" | "start" | "end" | "between">

renderours

The element to render instead of a <div>, like <ul /> or <nav />.

Type RenderProp

wrapours

Whether children wrap onto more rows when they don't fit. They do unless you say otherwise.

Type boolean