Inline
Arranges children in one row, separated by a step of the space scale, and wraps them when the row is full.
import { Avatar } from '@slotted/react/avatar';import { Badge } from '@slotted/react/badge';import { Inline } from '@slotted/react/inline';import { Text } from '@slotted/react/typography';export default function InlineBasic() { return ( <Inline> <Avatar name="Maria Chen" /> <Text weight="semibold">Maria Chen</Text> <Badge tone="success">Approver</Badge> <Badge tone="info">Finance</Badge> </Inline> );}Installation
The packages are a 0.x beta on npm, and their public API changes between beta releases without deprecation. One line installs the binding and the default theme.
pnpm add @slotted/react @slotted/theme @slotted/themesGap
gap sets the separation between items as a step on the space scale, from 0 for none to 12. The default is 4. Each row below holds the same three avatars at one step. An inline lays out one row; use Stack for a column.
import { Avatar } from '@slotted/react/avatar';import { Grid } from '@slotted/react/grid';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Text } from '@slotted/react/typography';const GAPS = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] as const;const PEOPLE = ['Maria Chen', 'Tomas Reyes', 'Priya Nair'] as const;export default function InlineGap() { return ( <Grid columns={2} gap={5} minItemWidth="sm"> {GAPS.map((gap) => ( <Stack key={gap} gap={1}> <Text size="xs" tone="muted"> Gap {gap} </Text> <Inline gap={gap}> {PEOPLE.map((person) => ( <Avatar key={person} name={person} size="sm" /> ))} </Inline> </Stack> ))} </Grid> );}Alignment
align positions items across the row, along the block axis. The default is center. start and end put each item on the top or bottom edge of the row, and stretch makes every item as tall as the tallest one, which is visible on the badge and the button.
align start
align center
align end
align stretch
import { Badge } from '@slotted/react/badge';import { Button } from '@slotted/react/button';import { Card, CardBody, CardHeader } from '@slotted/react/card';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Heading, Text } from '@slotted/react/typography';const ALIGNS = ['start', 'center', 'end', 'stretch'] as const;export default function InlineAlign() { return ( <Stack gap={4}> {ALIGNS.map((align) => ( <Card key={align}> <CardHeader> <Heading level={2} size="sm"> align {align} </Heading> </CardHeader> <CardBody> <Inline align={align}> <Text size="3xl" weight="semibold"> 14 </Text> <Badge tone="warning">Late pickups</Badge> <Button tone="secondary" variant="outline"> Review </Button> </Inline> </CardBody> </Card> ))} </Stack> );}Baseline
baseline aligns items by the baseline of their text, where center aligns their boxes. Use it when items carry text of different sizes, such as a label, a figure and a note.
align center
align baseline
import { Card, CardBody, CardHeader } from '@slotted/react/card';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Heading, Text } from '@slotted/react/typography';const ALIGNS = ['center', 'baseline'] as const;export default function InlineBaseline() { return ( <Stack gap={4}> {ALIGNS.map((align) => ( <Card key={align}> <CardHeader> <Heading level={2} size="sm"> align {align} </Heading> </CardHeader> <CardBody> <Inline align={align} gap={3}> <Text tone="muted">Open invoices</Text> <Text numeric="tabular" size="3xl" weight="semibold"> $48,200 </Text> <Text size="sm" tone="muted"> across 14 customers </Text> </Inline> </CardBody> </Card> ))} </Stack> );}Justification
justify positions items along the row and distributes the free space between them: start, center, end, between, around or evenly. Without justify, items sit at the start. between pushes the first and last items to the edges.
justify start
justify center
justify end
justify between
justify around
justify evenly
import { Badge } from '@slotted/react/badge';import { Card, CardBody, CardHeader } from '@slotted/react/card';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Heading } from '@slotted/react/typography';const JUSTIFIES = ['start', 'center', 'end', 'between', 'around', 'evenly'] as const;export default function InlineJustify() { return ( <Stack gap={4}> {JUSTIFIES.map((justify) => ( <Card key={justify}> <CardHeader> <Heading level={2} size="sm"> justify {justify} </Heading> </CardHeader> <CardBody> <Inline justify={justify}> <Badge tone="info">Packed</Badge> <Badge tone="warning">Shipped</Badge> <Badge tone="success">Delivered</Badge> </Inline> </CardBody> </Card> ))} </Stack> );}Wrapping
wrap defaults to wrap: items that do not fit move to the next line. nowrap keeps one line: the items shrink as far as they can and overflow a container narrower than that. The badges here shorten their text, so nowrap suits items that stay readable when they shrink.
wrap wrap
wrap nowrap
import { Badge } from '@slotted/react/badge';import { Card, CardBody, CardHeader } from '@slotted/react/card';import { Inline } from '@slotted/react/inline';import { Stack } from '@slotted/react/stack';import { Heading } from '@slotted/react/typography';const WRAPS = ['wrap', 'nowrap'] as const;const LABELS = [ 'Wholesale', 'Fragile', 'Priority shipping', 'Refrigerated', 'Hazardous materials', 'Signature required',] as const;export default function InlineWrap() { return ( <Stack gap={4}> {WRAPS.map((wrap) => ( <Card key={wrap}> <CardHeader> <Heading level={2} size="sm"> wrap {wrap} </Heading> </CardHeader> <CardBody> <Inline gap={2} wrap={wrap}> {LABELS.map((label) => ( <Badge key={label} tone="secondary" variant="outline"> {label} </Badge> ))} </Inline> </CardBody> </Card> ))} </Stack> );}Another element
An inline paints nothing and claims no semantics, so you choose the element. In React, render replaces the root element. In Angular, the slInline attribute goes on the element itself. A ul keeps the bullets and the indentation the browser gives it: an inline does not reset them. A row of fields with a submit button is a form, and align="end" sets the button on the bottom edge of the fields.
import { Button } from '@slotted/react/button';import { Field, FieldLabel } from '@slotted/react/field';import { Inline } from '@slotted/react/inline';import { TextField } from '@slotted/react/text-field';export default function InlineForm() { return ( <Inline align="end" gap={3} render={(props) => ( <form {...props} aria-label="Find orders" onSubmit={(event) => { event.preventDefault(); }} /> )} > <Field> <FieldLabel>Order number</FieldLabel> <TextField placeholder="SO-10482" /> </Field> <Field> <FieldLabel>Customer</FieldLabel> <TextField placeholder="Harbor Street store" /> </Field> <Button type="submit">Search</Button> </Inline> );}Accessibility
- Inline has no role and no ARIA. It arranges what you write inside it, and the items keep whatever semantics they already had.
- There is no axis that reverses the items. Visual order stays DOM order, which is what WCAG 2.2 SC 1.3.2 asks for (technique C27, failure F1) and what keeps the Tab order matching the page.
- Wrapping is the default because a row that cannot wrap has one answer to a narrow container: overflow it. nowrap accepts that overflow, so check WCAG 1.4.10 Reflow before choosing it.
- baseline is the alignment for items that carry text of different sizes. It puts the type on one line where centering only puts the boxes there.
- Alignment and distribution use the logical keywords, so a right-to-left document is the same row mirrored.
API
inline
Props
gap0 | 1 | … | 12Default4- Sets the separation between items as a step on the space scale.
align'start' | 'center' | 'end' | 'stretch' | 'baseline'Defaultcenter- Positions items across the row, along the block axis. baseline puts their text on one line.
justify'start' | 'center' | 'end' | 'between' | 'around' | 'evenly'- Positions items along the row and distributes the free space between them.
wrap'wrap' | 'nowrap'Defaultwrap- Decides what happens when the row is full. nowrap keeps one line and overflows a container narrower than it.
render(props) => ReactNode- Renders a different root element from the props it receives.
Theming
Each token is a CSS custom property: set it in a theme, or on any element to retune every inline inside it.
Theme tokens it reads
| Token | Default |
|---|---|
--slotted-space-1 | 0.125rem |
--slotted-space-10 | 2.5rem |
--slotted-space-11 | 3rem |
--slotted-space-12 | 4rem |
--slotted-space-2 | 0.25rem |
--slotted-space-3 | 0.375rem |
--slotted-space-4 | 0.5rem |
--slotted-space-5 | 0.75rem |
--slotted-space-6 | 1rem |
--slotted-space-7 | 1.25rem |
--slotted-space-8 | 1.5rem |
--slotted-space-9 | 2rem |