# Selectable Card

A form-compatible card with controlled or uncontrolled selection.

A form-compatible card with controlled or uncontrolled selection.

```tsx
import { SelectableCard, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function SelectableCardStatesExample() {
  const [selected, setSelected] = useState(["analytics"]);
  const options = [
    ["analytics", "Analytics", "Include product usage metrics."],
    ["audit", "Audit log", "Record member and policy activity."],
    ["reports", "Reports", "Include scheduled reports."],
  ] as const;

  return (
    <Stack gap="3" className="w-full max-w-2xl">
      <Stack direction="row" gap="3" wrap="wrap" align="stretch">
        {options.map(([value, title, description]) => (
          <SelectableCard
            key={value}
            label={title}
            variant={value === "reports" ? "white" : "default"}
            checked={selected.includes(value)}
            onCheckedChange={(checked) =>
              setSelected((current) =>
                checked ? [...current, value] : current.filter((item) => item !== value),
              )
            }
            className="min-w-56 flex-1"
          >
            <SelectableCard.Header>
              <SelectableCard.Title>{title}</SelectableCard.Title>
              <SelectableCard.Description>{description}</SelectableCard.Description>
            </SelectableCard.Header>
          </SelectableCard>
        ))}
        <SelectableCard label="Enterprise archive" disabled className="min-w-56 flex-1">
          <SelectableCard.Header>
            <SelectableCard.Title>Archive</SelectableCard.Title>
            <SelectableCard.Description>Requires an Enterprise plan.</SelectableCard.Description>
          </SelectableCard.Header>
        </SelectableCard>
      </Stack>
      <Text className="text-sm text-text-subtle" aria-live="polite">
        Selected: {selected.length ? selected.join(", ") : "None"}
      </Text>
    </Stack>
  );
}
```

## Import

```tsx
import { SelectableCard } from "@zentara-co/zenos-ui";
```

## Anatomy

SelectableCard reuses the Card compound parts, including `SelectableCard.Media`. A native checkbox or radio input (visually hidden) owns selection state. Clicking the card toggles the input unless the target is another interactive control.

```tsx
<SelectableCard label="Analytics" name="features" value="analytics">
  <SelectableCard.Media>{/* photo or video */}</SelectableCard.Media>
  <SelectableCard.Header>
    <SelectableCard.Title>Analytics</SelectableCard.Title>
    <SelectableCard.Description>Include usage metrics.</SelectableCard.Description>
  </SelectableCard.Header>
</SelectableCard>
```

## Media

`SelectableCard.Media` uses the same inset frame as [Card.Media](/components/card/#media). The hidden checkbox or radio still owns selection, and the selected border wraps the card around the frame. Leave other controls out of the frame so a click on the picture selects the card.

```tsx
import { Badge, SelectableCard, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function SelectableCardMediaExample() {
  const [kit, setKit] = useState("interior");

  return (
    <Stack gap="3" className="w-full">
      <Stack
        direction="row"
        gap="4"
        wrap="wrap"
        align="start"
        className="w-full justify-center"
        role="radiogroup"
        aria-label="Kits"
      >
        <SelectableCard
          label="Interior kit"
          name="kit-media"
          value="interior"
          selectionType="radio"
          checked={kit === "interior"}
          onCheckedChange={(checked) => checked && setKit("interior")}
          className="w-full max-w-72"
        >
          <SelectableCard.Media>
            <img
              src="https://images.unsplash.com/photo-1616486338812-3dadae4b4ace?auto=format&fit=crop&w=800&q=80"
              alt="Living room with plants and a rust-colored chair"
            />
            <Badge variant="solid" color="neutral" rounded className="absolute start-2 top-2">
              Best seller
            </Badge>
          </SelectableCard.Media>
          <SelectableCard.Header>
            <SelectableCard.Title>Interior kit</SelectableCard.Title>
            <SelectableCard.Description>
              48 rooms, 6 moods, every one editable.
            </SelectableCard.Description>
          </SelectableCard.Header>
        </SelectableCard>
        <SelectableCard
          label="Mountain retreat"
          name="kit-media"
          value="mountain"
          selectionType="radio"
          checked={kit === "mountain"}
          onCheckedChange={(checked) => checked && setKit("mountain")}
          className="w-full max-w-72"
        >
          <SelectableCard.Header>
            <SelectableCard.Title>Mountain retreat</SelectableCard.Title>
            <SelectableCard.Description>Media can close the card too.</SelectableCard.Description>
          </SelectableCard.Header>
          <SelectableCard.Media>
            <img
              src="https://images.unsplash.com/photo-1469474968028-56623f02e42e?auto=format&fit=crop&w=800&q=80"
              alt="Sunlit mountain valley above a green cliff"
            />
          </SelectableCard.Media>
        </SelectableCard>
      </Stack>
      <Text className="text-sm text-text-subtle" aria-live="polite">
        Selected: {kit === "interior" ? "Interior kit" : "Mountain retreat"}
      </Text>
    </Stack>
  );
}
```

## Checkbox selection

Use the default `selectionType="checkbox"` for multiple independent choices. Control selection with `checked` and `onCheckedChange`, or use `defaultChecked` for uncontrolled usage. The preview at the top of this page shows multi-select with a disabled card.

## Variants

`variant="default"`, `variant="grey"`, and `variant="white"` match [Card](/components/card/). White cards use a white surface in light mode and the default card background in dark mode. Hover and press fills follow the variant. Selected cards use the semantic `border-border-selected` token; disabled cards retain their muted treatment.

Disabled cards match ClickableCard: muted surface, `opacity-50`, and muted text on title and description.

## Radio selection

Use `selectionType="radio"` with a shared `name` for mutually exclusive choices. Control `checked` when the selected option belongs to application state.

```tsx
import { SelectableCard, Stack, Text } from "@zentara-co/zenos-ui";
import { useState } from "react";

function SelectableCardRadioExample() {
  const [plan, setPlan] = useState("monthly");

  return (
    <Stack gap="3" className="w-full max-w-2xl">
      <Stack
        direction="row"
        gap="3"
        wrap="wrap"
        align="stretch"
        role="radiogroup"
        aria-label="Billing cycle"
      >
        {[
          ["monthly", "Monthly", "Flexible monthly billing."],
          ["annual", "Annual", "Save with yearly billing."],
        ].map(([value, title, description]) => (
          <SelectableCard
            key={value}
            label={title}
            selectionType="radio"
            name="billing-cycle"
            value={value}
            checked={plan === value}
            onCheckedChange={(checked) => checked && setPlan(value)}
            className="min-w-56 flex-1"
          >
            <SelectableCard.Header>
              <SelectableCard.Title>{title}</SelectableCard.Title>
              <SelectableCard.Description>{description}</SelectableCard.Description>
            </SelectableCard.Header>
          </SelectableCard>
        ))}
      </Stack>
      <Text className="text-sm text-text-subtle">Billing cycle: {plan}</Text>
    </Stack>
  );
}
```

## Custom styling

Pass `className` on the root for custom surfaces and hover fills. The selected state sets `data-selected` on the root—combine it with utilities such as `data-[selected]:border-border-selected` when you override the default border color but still want the selected treatment.

Tint title and description on the compound parts when using accent backgrounds. Selection, focus, and form submission behavior are unchanged.

```tsx
import { SelectableCard } from "@zentara-co/zenos-ui";

function SelectableCardCustomExample() {
  return (
    <SelectableCard
      label="Pro plan"
      defaultChecked
      className="w-full max-w-md border-border-accent-indigo-default bg-background-accent-indigo-subtlest-default hover:bg-background-accent-indigo-subtlest-hover data-[selected]:border-border-selected"
    >
      <SelectableCard.Header>
        <SelectableCard.Title className="text-text-accent-indigo-bolder">
          Pro plan
        </SelectableCard.Title>
        <SelectableCard.Description className="text-text-accent-indigo-bolder/80">
          Selected cards still use the design system selected border.
        </SelectableCard.Description>
      </SelectableCard.Header>
    </SelectableCard>
  );
}
```

## SelectableCard or another component

Use SelectableCard inside forms when a choice should look like a card. Use [ClickableCard](/components/clickable-card/) for a single action without selection state. Use [Card](/components/card/) for static content.

## Anatomy

```text
SelectableCard.Root
SelectableCard.Header
SelectableCard.Title
SelectableCard.Description
SelectableCard.Action
SelectableCard.Content
SelectableCard.Media
SelectableCard.Footer
```

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| label | string | — | Accessible name for the hidden checkbox or radio input. |
| checked | boolean | — | Controlled selected state. |
| defaultChecked | boolean | false | Initial uncontrolled state. |
| onCheckedChange | (checked: boolean) => void | — | Runs after selection changes. |
| name / value | string | — | Hidden form input metadata. |
| selectionType | checkbox \| radio | checkbox | Hidden input type. |
| disabled | boolean | false | Prevents selection and applies muted, reduced-opacity styling. |
| variant | default \| grey \| white | default | Card surface; hover fills match the chosen variant. |
| className | string | — | Merged last on the root. Custom surfaces and data-[selected] border utilities compose with selection state. |
| native props | React.HTMLAttributes<HTMLDivElement> | — | Forwards native attributes, events, aria-*, data-*, className, style, and ref. |

Unless narrowed above, each DOM-rendering part also accepts its underlying native or Base UI props, including className, style, aria-*, and data-*.

## Accessibility

`SelectableCard` uses a native checkbox or radio input, so it participates in keyboard navigation and form submission. Give every card a concise `label`, group radio cards with an accessible group name, and use `disabled` when a choice is unavailable.

Source: https://zenos-ui.pages.dev/components/selectable-card/