---
title: "List · Base UI — StyleX Blocks"
description: "Ordered and unordered lists with native markers or custom icon indicators."
url: "https://stylexblocks.com/components/base-ui/list/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# List

Ordered and unordered lists with native markers or custom icon indicators.

- Behavior engine: Base UI
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/list.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/list.md)
- Category: Display
- Variants: marker, plain
- HTML page: https://stylexblocks.com/components/base-ui/list/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style base-ui
```

Then add the item as source you own:

```sh
npx stylexblocks add list
```

Equivalent: `npx shadcn add @stylexblocks/list`. Registry item JSON: https://stylexblocks.com/r/base-ui/list.json

## Usage

```tsx
import { List } from "#components/ui/base-ui/list.tsx";

const features = [
  "Compiles to static CSS",
  "Zero runtime style objects",
  "Types for every token",
];

export function Example() {
  return (
    // variant resolves once on Root; items inherit it via context.
    // "marker" uses native list markers; "plain" swaps them for indicators.
    <List.Root variant="plain">
      {features.map((text) => (
        <List.Item key={text}>
          <List.Indicator>
            <CheckIcon />
          </List.Indicator>
          {text}
        </List.Item>
      ))}
    </List.Root>
  );
}

// ordered lists compose through the render prop:
// <List.Root render={<ol />}>…</List.Root>
```

## Source

`components/ui/base-ui/list.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createSlotRecipeContext } from "#lib/base-ui/create-slot-recipe-context.tsx";
import { defineSlotRecipe } from "#lib/recipe-props.ts";
const listRoot = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    gap: 'var(--list-gap)',
  },
})

const listRootVariants = stylex.create({
  marker: {
    listStyle: 'revert',
    listStylePosition: 'inside',
  },
})

const listItem = stylex.create({
  base: {
    whiteSpace: 'normal',
    display: 'list-item',
  },
})

const listItemVariants = stylex.create({
  marker: {},
  plain: {
    alignItems: 'flex-start',
    display: 'inline-flex',
  },
})

const listItemAligns = stylex.create({
  center: {
    alignItems: 'center',
  },
  start: {
    alignItems: 'flex-start',
  },
  end: {
    alignItems: 'flex-end',
  },
})

const listIndicator = stylex.create({
  base: {
    marginEnd: 2,
    minHeight: '1lh',
    flexShrink: 0,
    display: 'inline-block',
    verticalAlign: 'middle',
  },
})

export type ListVariant = keyof typeof listRootVariants

export type ListAlign = keyof typeof listItemAligns

// The root renders a real <ul>; markers sit inside (list-style-position:
// inside), so UA margins/padding are reset here rather than in the recipe.
const listLocal = stylex.create({
  ul: { marginBlock: 0, paddingInlineStart: 0 },
});

// defineSlotRecipe validates the shape at compile time: default values must
// exist in the axis maps, and slot keys must be `styles` or a declared axis
const listSlotRecipe = defineSlotRecipe({
  slots: {
    root: { styles: listRoot, variants: listRootVariants },
    item: { styles: listItem, variants: listItemVariants },
    indicator: { styles: listIndicator },
  },
  defaultVariants: { variant: "marker" },
});

/**
 * List — recipe and component colocated in one file. `<List.Root variant>`
 * resolves the recipe once and items inherit it through context; each part
 * composes via `render` (e.g. `<List.Root render={<ol />}>…</List.Root>`
 * for ordered lists). The root's sparse variant map (marker only) resolves
 * through an explicit resolver; the indicator replaces the native marker in
 * the plain variant.
 */
const { withProvider, withContext } = createSlotRecipeContext(listSlotRecipe);

export const List = {
  Root: withProvider(
    "ul",
    (v) => [listRoot.base, v.variant === "marker" && listRootVariants.marker, listLocal.ul],
    "ListRoot",
  ),
  Item: withContext("li", "item", "ListItem"),
  Indicator: withContext("span", "indicator", "ListIndicator"),
};
```
