Skip to main content

Common Examples

import { Chip, Grid, SelectCard, Text } from "@servicetitan/anvil2";

const data = [/*...data for select cards...*/]

function ExampleComponent() {
  return (
    <SelectCard.Group
      legend="Example multiple selection"
      required={false}
      selectionMode="multiple"
      onChange={(e) => {
        console.log(e);
      }}
    >
      <Grid gap="4" templateColumns="repeat(3, 1fr)">
        {data.map((item) => (
          <SelectCard key={item.id} id={item.id}>
            <Grid templateColumns="repeat(2, 1fr)" gap="4">
              <Text>{item.label}</Text>
              <Text style={{ textAlign: "right" }}>{item.cost}</Text>
              <Text>{item.timeEstimate}</Text>
              <Chip label={item.customerName} />
            </Grid>
          </SelectCard>
        ))}
    </SelectCard.Group>
  );
}

SelectCard Components

The Anvil2 SelectCard is typically used within a SelectCard.Group. Under the hood SelectCard can either be a radio or a checkbox, and accepts all of the props associated with those HTML inputs.
  • SelectCard.Group: the parent component used to configure a group of SelectCard items.
  • SelectCard: used to create a card input to use with a group.

Validation

SelectCards have an errored state, which can be triggered with an onChange.

Select Indicator Visual

Use the showSelectIndicator prop to display a checkbox or radio indicator in a separate column on the left side of the card. The indicator type is automatically determined by the selectionMode from SelectCard.Group.
The showSelectIndicator prop is available for both SelectCard and SelectCard.Group, but in most cases it is recommended to use it with SelectCard.Group to show the indicator on all cards in the group.
Last modified on January 23, 2026