# Track (/components/layout/track)



`Track` aligns content on the inline axis. Use it when icons, avatars, controls, or other supporting
content need to stay aligned with content that can grow or wrap. Read [Layout](/docs/layout) to
choose a layout component.

Pass content to `railStart` or `railEnd` to place it before or after `children`. Rails keep their
size. `children` uses the remaining inline space and can shrink when space is limited.

apps/docs/src/examples/track/basic.tsx

```tsx
import { Box } from '@luke-ui/react/box';
import { Icon } from '@luke-ui/react/icon';
import { Track } from '@luke-ui/react/track';

export default () => {
	return (
		<Box maxInlineSize="18rem">
			<Track gap="sp8" railAlignment="firstLine" railStart={<Icon name="checkCircle" />}>
				Example message that wraps onto multiple lines when the available space is limited.
			</Track>
		</Box>
	);
};
```

## Rails and sizing [#rails-and-sizing]

When space is limited, `children` can shrink below its intrinsic size instead of forcing Track
wider. This avoids common layout blowouts with long or truncating content.

Track does not apply wrapping or truncation itself. Content can still overflow when it has no way to
wrap or otherwise constrain itself.

## Alignment [#alignment]

Use `center` when the rail should align with the whole content block. When the content wraps, the
rail is centred against the resulting block.

Use `firstLine` when the rail should stay aligned with the first line as the content wraps. This is
useful for icons, avatars, and controls beside text. Use `start` or `end` when the rail should align
with the start or end of the content block. `start` is the default.

`firstLine` works best when Track and its content inherit the same line height. A child with a
different line height, such as a `Heading` or differently sized `Text`, does not change the rail's
alignment point.

apps/docs/src/examples/track/alignment.tsx

```tsx
import { Box } from '@luke-ui/react/box';
import { Icon } from '@luke-ui/react/icon';
import { Track } from '@luke-ui/react/track';
import { Comparison, ComparisonItem } from '#docs';

export default () => {
	return (
		<Comparison>
			<ComparisonItem label="Center">
				<Box maxInlineSize="18rem">
					<Track gap="sp8" railAlignment="center" railStart={<Icon name="checkCircle" />}>
						Example message that wraps onto multiple lines when the available space is limited.
					</Track>
				</Box>
			</ComparisonItem>
			<ComparisonItem label="First line">
				<Box maxInlineSize="18rem">
					<Track gap="sp8" railAlignment="firstLine" railStart={<Icon name="checkCircle" />}>
						Example message that wraps onto multiple lines when the available space is limited.
					</Track>
				</Box>
			</ComparisonItem>
		</Comparison>
	);
};
```

## Avatar and text [#avatar-and-text]

apps/docs/src/examples/track/avatar.tsx

```tsx
import { Box } from '@luke-ui/react/box';
import { Stack } from '@luke-ui/react/stack';
import { Text } from '@luke-ui/react/text';
import { Track } from '@luke-ui/react/track';

export default () => {
	return (
		<Track
			gap="sp12"
			railAlignment="center"
			railStart={
				<Box
					backgroundColor="neutral.subtle.rest"
					blockSize="3rem"
					borderRadius="full"
					inlineSize="3rem"
				/>
			}
		>
			<Stack gap="sp4">
				<Text fontWeight="emphasis">Boricio Jones</Text>
				<Text typography="caption">Product designer</Text>
			</Stack>
		</Track>
	);
};
```

## Choose the rendered element [#choose-the-rendered-element]

Set `elementType="li"` when Track is a direct child of `ul` or `ol`.

apps/docs/src/examples/track/element.tsx

```tsx
import { Icon } from '@luke-ui/react/icon';
import { Track } from '@luke-ui/react/track';

export default () => {
	return (
		<ul>
			<Track elementType="li" gap="sp8" railStart={<Icon name="checkCircle" />}>
				First item
			</Track>
			<Track elementType="li" gap="sp8" railStart={<Icon name="checkCircle" />}>
				Second item
			</Track>
		</ul>
	);
};
```

Set `elementType="span"` when Track needs to flow inside phrasing content. Its rails and `children`
must also be valid phrasing content.

apps/docs/src/examples/track/element-span.tsx

```tsx
import { Icon } from '@luke-ui/react/icon';
import { Track } from '@luke-ui/react/track';

export default () => {
	return (
		<p>
			Example text with{' '}
			<Track elementType="span" gap="sp4" railStart={<Icon name="checkCircle" />}>
				inline content
			</Track>{' '}
			in the middle.
		</p>
	);
};
```

## API [#api]

<ComponentPropsTable
  id="type-table-track.tsx-TrackProps"
  type="{
  &#x22;id&#x22;: &#x22;track.tsx-TrackProps&#x22;,
  &#x22;name&#x22;: &#x22;TrackProps&#x22;,
  &#x22;description&#x22;: &#x22;Props for `Track`.&#x22;,
  &#x22;entries&#x22;: [
    {
      &#x22;name&#x22;: &#x22;children&#x22;,
      &#x22;description&#x22;: &#x22;Content that uses the remaining inline space.&#x22;,
      &#x22;tags&#x22;: [],
      &#x22;type&#x22;: &#x22;ReactNode&#x22;,
      &#x22;simplifiedType&#x22;: &#x22;ReactNode&#x22;,
      &#x22;required&#x22;: false,
      &#x22;deprecated&#x22;: false
    },
    {
      &#x22;name&#x22;: &#x22;elementType&#x22;,
      &#x22;description&#x22;: &#x22;Root element.\n\nUse `li` as a direct child of `ul` or `ol`. Use `span` when Track needs to remain inside phrasing\ncontent.&#x22;,
      &#x22;tags&#x22;: [
        {
          &#x22;name&#x22;: &#x22;default&#x22;,
          &#x22;text&#x22;: &#x22;div&#x22;
        }
      ],
      &#x22;type&#x22;: &#x22;TrackElementType | undefined&#x22;,
      &#x22;simplifiedType&#x22;: &#x22;union&#x22;,
      &#x22;required&#x22;: false,
      &#x22;deprecated&#x22;: false
    },
    {
      &#x22;name&#x22;: &#x22;gap&#x22;,
      &#x22;description&#x22;: &#x22;Space between each rendered rail and `children`.&#x22;,
      &#x22;tags&#x22;: [],
      &#x22;type&#x22;: &#x22;RequiredInitialResponsive<ResponsiveValue<\&#x22;0\&#x22; | \&#x22;sp12\&#x22; | \&#x22;sp16\&#x22; | \&#x22;sp24\&#x22; | \&#x22;sp32\&#x22; | \&#x22;sp4\&#x22; | \&#x22;sp40\&#x22; | \&#x22;sp48\&#x22; | \&#x22;sp64\&#x22; | \&#x22;sp8\&#x22; | \&#x22;sp96\&#x22;> | undefined> | undefined&#x22;,
      &#x22;simplifiedType&#x22;: &#x22;union&#x22;,
      &#x22;required&#x22;: false,
      &#x22;deprecated&#x22;: false
    },
    {
      &#x22;name&#x22;: &#x22;railEnd&#x22;,
      &#x22;description&#x22;: &#x22;Content shown after `children` that keeps its intrinsic inline size.&#x22;,
      &#x22;tags&#x22;: [],
      &#x22;type&#x22;: &#x22;ReactNode&#x22;,
      &#x22;simplifiedType&#x22;: &#x22;ReactNode&#x22;,
      &#x22;required&#x22;: false,
      &#x22;deprecated&#x22;: false
    },
    {
      &#x22;name&#x22;: &#x22;railAlignment&#x22;,
      &#x22;description&#x22;: &#x22;Cross-axis alignment of the rails.\n\n`firstLine` uses Track's inherited line height. A different line height inside `children` does\nnot change the alignment point.&#x22;,
      &#x22;tags&#x22;: [
        {
          &#x22;name&#x22;: &#x22;default&#x22;,
          &#x22;text&#x22;: &#x22;start&#x22;
        }
      ],
      &#x22;type&#x22;: &#x22;\&#x22;center\&#x22; | \&#x22;end\&#x22; | \&#x22;firstLine\&#x22; | \&#x22;start\&#x22; | undefined&#x22;,
      &#x22;simplifiedType&#x22;: &#x22;union&#x22;,
      &#x22;required&#x22;: false,
      &#x22;deprecated&#x22;: false
    },
    {
      &#x22;name&#x22;: &#x22;railStart&#x22;,
      &#x22;description&#x22;: &#x22;Content shown before `children` that keeps its intrinsic inline size.&#x22;,
      &#x22;tags&#x22;: [],
      &#x22;type&#x22;: &#x22;ReactNode&#x22;,
      &#x22;simplifiedType&#x22;: &#x22;ReactNode&#x22;,
      &#x22;required&#x22;: false,
      &#x22;deprecated&#x22;: false
    },
    {
      &#x22;name&#x22;: &#x22;ref&#x22;,
      &#x22;description&#x22;: &#x22;Ref to the rendered element.&#x22;,
      &#x22;tags&#x22;: [],
      &#x22;type&#x22;: &#x22;Ref<HTMLElement> | undefined&#x22;,
      &#x22;simplifiedType&#x22;: &#x22;union&#x22;,
      &#x22;required&#x22;: false,
      &#x22;deprecated&#x22;: false
    },
    {
      &#x22;deprecated&#x22;: false,
      &#x22;description&#x22;: &#x22;`TrackProps` also accepts compatible DOM and ARIA attributes and event handlers for its rendered element.&#x22;,
      &#x22;name&#x22;: &#x22;__nativePropsForwarding&#x22;,
      &#x22;required&#x22;: true,
      &#x22;simplifiedType&#x22;: &#x22;&#x22;,
      &#x22;tags&#x22;: [],
      &#x22;type&#x22;: &#x22;&#x22;
    }
  ]
}"
/>
