Inline
Inline is a primitive component based on flexbox that manages the horizontal layout of direct children.
Usage
Inline arranges children horizontally with consistent spacing.
import { Inline } from '@hardwater/teardrop';
<Inline gap="small">
<Button>Action 1</Button>
<Button>Action 2</Button>
</Inline>
Gap
Control spacing between children:
<Inline gap="xsmall">Tight spacing</Inline>
<Inline gap="small">Compact spacing</Inline>
<Inline gap="medium">Default spacing</Inline>
<Inline gap="large">Comfortable spacing</Inline>
Alignment
Align Items
<Inline align="start">Align start</Inline>
<Inline align="center">Align center (default)</Inline>
<Inline align="end">Align end</Inline>
<Inline align="stretch">Stretch</Inline>
<Inline align="baseline">Baseline</Inline>
Justify Content
<Inline justify="start">Justify start (default)</Inline>
<Inline justify="center">Justify center</Inline>
<Inline justify="end">Justify end</Inline>
<Inline justify="space-between">Space between</Inline>
<Inline justify="space-around">Space around</Inline>
Wrapping
<Inline wrap>Wrap children</Inline>
API
Props
| Prop | Type | Default | Description |
|---|---|---|---|
gap | SpacingToken | - | Spacing between children |
align | 'start' | 'center' | 'end' | 'stretch' | 'baseline' | 'center' | Align items |
justify | 'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'start' | Justify content |
wrap | boolean | false | Wrap children |
as | string | Component | 'div' | Element or component to render as |
Examples
Button Group
<Inline gap="small">
<Button variant="primary">Save</Button>
<Button variant="secondary">Cancel</Button>
</Inline>
Icon with Text
<Inline gap="small" align="center">
<Icon name="info" />
<Text>Information message</Text>
</Inline>
Tags
<Inline gap="xsmall" wrap>
<Badge>Tag 1</Badge>
<Badge>Tag 2</Badge>
<Badge>Tag 3</Badge>
<Badge>Tag 4</Badge>
</Inline>
Navigation
<Inline as="nav" gap="large">
<Link href="/">Home</Link>
<Link href="/about">About</Link>
<Link href="/contact">Contact</Link>
</Inline>
Form Actions
<Inline gap="medium" justify="end">
<Button variant="secondary">Cancel</Button>
<Button variant="primary">Submit</Button>
</Inline>
Best Practices
- Appropriate gaps - Use smaller gaps for related items, larger for unrelated
- Semantic HTML - Use
asprop for semantic elements (<nav>,<header>, etc.) - Wrapping - Enable wrap for responsive layouts
- Composition - Combine with Box for padding and backgrounds
Related
- Box - Container component
- Stack - Vertical layout
- Spacing Tokens