Skip to main content

Common Examples

import { ListView, Text } from "@servicetitan/anvil2";

function ExampleComponent() {
  return (
    <ListView>
      <ListView.Option label="first">
        <Text>First Value</Text>
      </ListView.Option>
      <ListView.Option label="second">
        <Text>Second Value</Text>
      </ListView.Option>
      <ListView.Option label="third">
        <Text>Third Value</Text>
      </ListView.Option>
    </ListView>
  );
}

Creating selectable list views

The ListView component can be used to easily create selectable lists using the label prop and custom content as children of each ListView.Option.

Indeterminate list views

The indeterminate prop can be used when the selection of items is controlled to render the checkbox as indeterminate, instead of checked or not checked. This is useful when building a nested structure.Note: the logic to determine which items are indeterminate is not included, since there are various use cases. Simply pass the items that should be indeterminate to the prop.

Using items objects with list views

The items prop of a ListView can also be passed an array of objects which are passed to the children of the list view. Each item object should have a label, but any other arbitrary attributes are allowed.
const Items = [
  { label: "Item 1", imgUrl: "#" },
  { label: "Item 2", imgUrl: "#", disabled: true },
  { label: "Item 3" },
];

export const ListViewExample = () => (
  <ListView items={Items}>
    {(items) =>
      items.map((item) => (
        <ListView.Option key={item.label} item={item} disabled={item.disabled}>
          <Avatar image={item.imgUrl} name={item.label} />
          <Text>{item.label}</Text>
        </ListView.Option>
      ))
    }
  </ListView>
);
Last modified on January 23, 2026