List

A bulleted or numbered list.

  • Create a new project and give it a short, clear name
  • Invite your teammates and choose a role for each of them
  • Connect your own domain so the site is ready to go live

Usage

Code
import { List } from '@leverui/components';
Code
<List.Root>
  <List.Item>Item 1</List.Item>
  <List.Item>Item 2</List.Item>
</List.Root>

List.Root renders a ul with role="list" and each List.Item an li. Pass as="ol" for a numbered list.

Examples

Ordered

Pass the as="ol" prop to create an ordered list

  1. Create a new project and give it a short, clear name
  2. Invite your teammates and choose a role for each of them
  3. Connect your own domain so the site is ready to go live

Icon

Use the List.Indicator component to add an icon to the list

  • Create a new project and give it a short, clear name
  • Invite your teammates and choose a role for each of them
  • Connect your own domain so the site is ready to go live

Nested

Here's an example of a nested list

  • Top-level item
  • Top-level item
  • Top-level item with a list inside
    • Nested item
    • Nested item
    • Nested item
  • Top-level item

Marker Style

Use the ::marker CSS selector to style the marker of the list

  1. Any breach of these terms by you or by someone using your account;
  2. Your use of the service, including anything you upload, share or store, and any loss of money, data or privacy that follows from it; and
  3. Any attempt to disrupt the service on purpose, for example by installing or spreading a virus, a worm, spyware, adware or any other program that runs on our systems, or that uses their processing time, at a moment when you are not directly using that program yourself for the purpose it was made for.

Props

PropDefaultTypeDescription
variantmarker'marker' | 'plain'List style. marker shows bullets or numbers. plain hides them.
asulNative HTML tagHTML tag to render.
asChild—Solid render functionRender your own element with the list's props.
unstyled—booleanTurn off the Lever UI styles.
align—'center' | 'start' | 'end'How item content lines up, such as an icon beside its text.

variant and align are responsive, such as align={{ base: 'start', md: 'end' }}. Every part takes native HTML attributes, a ref, class, style, and unstyled. An indicator's ref points to the element you render with asChild. A nested List.Root does not take its look from the outer list.

List.RootPropsProvider sets default props for the lists inside it. Pass a value or a function that returns one. A prop on a list wins. If the function reads a signal, the lists update in place.

Customize with CSS

Import @leverui/components/styles.css once in your app. Set --leverui-list-gap on a list or a wrapping class to change the space between items and nested lists.

Code
.compact-list {
  --leverui-list-gap: var(--leverui-spacing-1);
}

Classes: .leverui-list__root, .leverui-list__item, and .leverui-list__indicator. Put one on your own element inside a List.Root and it picks up the list's variant. The root has data-variant and data-align, plus one per screen size you set, such as data-variant-md.

Style the bullet or number with ::marker. Lever UI's styles sit in a CSS layer, so your unlayered CSS wins at equal specificity. No object CSS, general style props, custom recipes, or style object hooks.

Explorer

Click a part name in the sidebar to highlight it in the preview.

Component Anatomy

Hover to highlight, click to select parts