---
title: "Checkbox Card · UI SDK — StyleX Blocks"
description: "Selectable cards with label, description, and checkmark indicator in surface, subtle, outline, and solid variants."
url: "https://stylexblocks.com/components/ui-sdk/checkbox-card/"
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/"
---

# Checkbox Card

Selectable cards with label, description, and checkmark indicator in surface, subtle, outline, and solid variants.

- Behavior engine: UI SDK
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/checkbox-card.md), [Base UI](https://stylexblocks.com/components/base-ui/checkbox-card.md)
- Category: Form
- Variants: surface, subtle, outline, solid
- Sizes: sm, md, lg
- Used in blocks: [Vertical Wizard](https://stylexblocks.com/block/ui-sdk/form-wizard-vertical.md)
- HTML page: https://stylexblocks.com/components/ui-sdk/checkbox-card/

## Install

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

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

Then add the item as source you own:

```sh
npx stylexblocks add checkbox-card
```

Equivalent: `npx shadcn add @stylexblocks/checkbox-card`. Registry item JSON: https://stylexblocks.com/r/ui-sdk/checkbox-card.json

## Usage

```tsx
import { CheckboxCard } from "#components/ui/ui-sdk/checkbox-card.tsx";
import { indigoPalette } from "@stylexblocks/ui/themes/palettes.ts";

export function Example() {
  return (
    // Root is UI SDK's Checkbox styled as a card; it stamps data-checked on
    // itself and the Indicator, so every part styles itself from it
    <CheckboxCard.Root defaultChecked variant="outline" size="md" palette={indigoPalette}>
      <CheckboxCard.Control>
        <CheckboxCard.Content>
          <CheckboxCard.Label>Analytics</CheckboxCard.Label>
          <CheckboxCard.Description>Track page views</CheckboxCard.Description>
        </CheckboxCard.Content>
        <CheckboxCard.Indicator />
      </CheckboxCard.Control>
    </CheckboxCard.Root>
  );
}

// controlled: <CheckboxCard.Root checked={on} onCheckedChange={setOn}>
```

## Source

`components/ui/ui-sdk/checkbox-card.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import {
  Checkbox as UiSdkCheckbox,
  CheckboxIndicator as UiSdkCheckboxIndicator,
} from "@ui-sdk/react/checkbox";
import { createSlotRecipeContext } from "#lib/ui-sdk/create-slot-recipe-context.tsx";
import {
  defineSlotRecipe,
  fromMap,
  resolveSlotStyles,
  type SlotRecipeVariants,
} from "#lib/recipe-props.ts";
import { colorPalette } from '@stylexblocks/ui/color-palette.stylex.ts'
import { colors } from '@stylexblocks/ui/tokens/colors.stylex.ts'
import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'
import { fontWeights } from '@stylexblocks/ui/tokens/font-weights.stylex.ts'
import { lineHeights } from '@stylexblocks/ui/tokens/line-heights.stylex.ts'
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { semanticRadii } from '@stylexblocks/ui/semantic-tokens/radii.stylex.ts'
import { sizes } from '@stylexblocks/ui/tokens/sizes.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const checkboxCardRoot = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    userSelect: 'none',
    position: 'relative',
    borderRadius: semanticRadii.panel,
    flex: 1,
    outlineWidth: {
      default: null,
      ':focus-visible': '1px',
    },
    outlineOffset: {
      default: null,
      ':focus-visible': '2px',
    },
    outlineStyle: {
      default: null,
      ':focus-visible': 'solid',
    },
    outlineColor: {
      default: null,
      ':focus-visible': colorPalette.focusRing,
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
    opacity: {
      default: null,
      ':is(:disabled, [disabled], [data-disabled])': 0.8,
    },
    borderColor: {
      default: null,
      ':is(:disabled, [disabled], [data-disabled])':
        semanticColors.borderSubtle,
    },
    outline: {
      default: null,
      ':is([data-invalid], [aria-invalid="true"])': '2px solid',
    },
  },
})

const checkboxCardRootSizes = stylex.create({
  sm: {
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.sm,
  },
  md: {
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.sm,
  },
  lg: {
    fontSize: fontSizes.md,
    lineHeight: lineHeights.md,
  },
})

const checkboxCardRootVariants = stylex.create({
  surface: {
    borderWidth: '1px',
    borderColor: {
      default: semanticColors.border,
      ':is(:disabled, [disabled], [data-disabled])':
        semanticColors.borderSubtle,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.muted,
    },
    backgroundColor: {
      default: null,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.subtle,
      ':is(:disabled, [disabled], [data-disabled])': semanticColors.bgMuted,
    },
    color: {
      default: null,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.fg,
    },
  },
  subtle: {
    backgroundColor: semanticColors.bgMuted,
  },
  outline: {
    borderWidth: '1px',
    borderColor: {
      default: semanticColors.border,
      ':is(:disabled, [disabled], [data-disabled])':
        semanticColors.borderSubtle,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.solid,
    },
    boxShadow: {
      default: null,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        '0 0 0 1px var(--shadow-color)',
    },
    '--shadow-color': {
      default: null,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.solid,
    },
  },
  solid: {
    borderWidth: '1px',
    backgroundColor: {
      default: null,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.solid,
    },
    color: {
      default: null,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.contrast,
    },
    borderColor: {
      default: null,
      ':is(:disabled, [disabled], [data-disabled])':
        semanticColors.borderSubtle,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.solid,
    },
  },
})

const checkboxCardRootJustifys = stylex.create({
  start: {
    '--checkbox-card-justify': 'flex-start',
  },
  end: {
    '--checkbox-card-justify': 'flex-end',
  },
  center: {
    '--checkbox-card-justify': 'center',
  },
})

const checkboxCardRootAligns = stylex.create({
  start: {
    '--checkbox-card-align': 'flex-start',
  },
  end: {
    '--checkbox-card-align': 'flex-end',
  },
  center: {
    '--checkbox-card-align': 'center',
  },
})

const checkboxCardControl = stylex.create({
  base: {
    display: 'inline-flex',
    flex: 1,
    position: 'relative',
    borderRadius: semanticRadii.panel,
    justifyContent: 'var(--checkbox-card-justify)',
    alignItems: 'var(--checkbox-card-align)',
  },
})

const checkboxCardControlSizes = stylex.create({
  sm: {
    padding: spacing._3,
    gap: spacing._1_5,
  },
  md: {
    padding: spacing._4,
    gap: spacing._2_5,
  },
  lg: {
    padding: spacing._4,
    gap: spacing._3_5,
  },
})

const checkboxCardControlVariants = stylex.create({
  subtle: {
    backgroundColor: {
      default: null,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.muted,
    },
    color: {
      default: null,
      ':is(:checked, [data-checked], [aria-checked="true"], [data-state="checked"])':
        colorPalette.fg,
    },
  },
})

const checkboxCardControlOrientations = stylex.create({
  vertical: {
    flexDirection: 'column',
  },
  horizontal: {
    flexDirection: 'row',
  },
})

const checkboxCardLabel = stylex.create({
  base: {
    fontWeight: fontWeights.medium,
    display: 'flex',
    alignItems: 'center',
    gap: spacing._2,
    opacity: {
      default: null,
      ':is(:disabled, [disabled], [data-disabled])': 0.5,
    },
  },
})

const checkboxCardDescription = stylex.create({
  base: {
    opacity: 0.64,
    fontSize: fontSizes.sm,
    lineHeight: lineHeights.sm,
  },
})

const checkboxCardAddon = stylex.create({
  base: {
    opacity: {
      default: null,
      ':is(:disabled, [disabled], [data-disabled])': 0.5,
    },
  },
})

const checkboxCardAddonSizes = stylex.create({
  sm: {
    paddingInline: spacing._3,
    paddingBlock: spacing._1_5,
    borderTopWidth: '1px',
  },
  md: {
    paddingInline: spacing._4,
    paddingBlock: spacing._2,
    borderTopWidth: '1px',
  },
  lg: {
    paddingInline: spacing._4,
    paddingBlock: spacing._2,
    borderTopWidth: '1px',
  },
})

const checkboxCardIndicator = stylex.create({
  base: {
    display: 'inline-flex',
    alignItems: 'center',
    justifyContent: 'center',
    flexShrink: 0,
    color: colors.white,
    borderWidth: '1px',
    borderColor: {
      default: 'transparent',
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
    borderRadius: semanticRadii.control,
    outlineWidth: {
      default: null,
      ':focus-visible': '1px',
    },
    outlineOffset: {
      default: null,
      ':focus-visible': '2px',
    },
    outlineStyle: {
      default: null,
      ':focus-visible': 'solid',
    },
    outlineColor: {
      default: null,
      ':focus-visible': colorPalette.focusRing,
    },
    opacity: {
      default: null,
      ':is(:disabled, [disabled], [data-disabled])': 0.5,
    },
  },
})

const checkboxCardIndicatorSizes = stylex.create({
  sm: {
    width: sizes._3_5,
    height: sizes._3_5,
  },
  md: {
    width: sizes._4,
    height: sizes._4,
    padding: spacing._0_5,
  },
  lg: {
    width: sizes._5,
    height: sizes._5,
    padding: spacing._0_5,
  },
})

const checkboxCardIndicatorVariants = stylex.create({
  surface: {
    borderColor: {
      default: semanticColors.borderEmphasized,
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
  },
  subtle: {},
  outline: {
    borderColor: {
      default: semanticColors.borderEmphasized,
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
  },
  solid: {
    borderColor: {
      default: semanticColors.border,
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
    color: colorPalette.fg,
  },
})

const checkboxCardContent = stylex.create({
  base: {
    display: 'flex',
    flexDirection: 'column',
    flex: 1,
    gap: spacing._1,
    justifyContent: 'var(--checkbox-card-justify)',
    alignItems: 'var(--checkbox-card-align)',
  },
})

const checkboxCardContentAligns = stylex.create({
  start: {
    textAlign: 'start',
  },
  end: {
    textAlign: 'end',
  },
  center: {
    textAlign: 'center',
  },
})

export type CheckboxCardSize = keyof typeof checkboxCardRootSizes

export type CheckboxCardVariant = keyof typeof checkboxCardRootVariants

export type CheckboxCardJustify = keyof typeof checkboxCardRootJustifys

export type CheckboxCardAlign = keyof typeof checkboxCardRootAligns

export type CheckboxCardOrientation =
  keyof typeof checkboxCardControlOrientations

const checkboxCardRecipe = defineSlotRecipe({
  slots: {
    root: {
      styles: checkboxCardRoot,
      sizes: checkboxCardRootSizes,
      variants: checkboxCardRootVariants,
      justifys: checkboxCardRootJustifys,
      aligns: checkboxCardRootAligns,
    },
    control: {
      styles: checkboxCardControl,
      sizes: checkboxCardControlSizes,
      variants: checkboxCardControlVariants,
      orientations: checkboxCardControlOrientations,
    },
    label: { styles: checkboxCardLabel },
    description: { styles: checkboxCardDescription },
    indicator: {
      styles: checkboxCardIndicator,
      sizes: checkboxCardIndicatorSizes,
      variants: checkboxCardIndicatorVariants,
    },
    content: { styles: checkboxCardContent, aligns: checkboxCardContentAligns },
  },
  defaultVariants: {
    size: "md",
    variant: "outline",
    align: "start",
    justify: "start",
    orientation: "horizontal",
  },
});

const cardChecked = stylex.create({
  surface: {
    backgroundColor: { default: null, ":is([data-checked])": colorPalette.subtle },
    color: { default: null, ":is([data-checked])": colorPalette.fg },
    borderColor: { default: null, ":is([data-checked])": colorPalette.muted },
  },
  subtle: {
    backgroundColor: { default: null, ":is([data-checked])": colorPalette.muted },
    color: { default: null, ":is([data-checked])": colorPalette.fg },
  },
  outline: {
    boxShadow: { default: null, ":is([data-checked])": `0 0 0 1px ${colorPalette.solid}` },
    borderColor: { default: null, ":is([data-checked])": colorPalette.solid },
  },
  solid: {
    backgroundColor: { default: null, ":is([data-checked])": colorPalette.solid },
    color: { default: null, ":is([data-checked])": colorPalette.contrast },
    borderColor: { default: null, ":is([data-checked])": colorPalette.solid },
  },
});

const cardIndicatorChecked = stylex.create({
  surface: {
    backgroundColor: { default: null, ":is([data-checked])": colorPalette.solid },
    color: { default: null, ":is([data-checked])": colorPalette.contrast },
    borderColor: { default: null, ":is([data-checked])": colorPalette.solid },
  },
  subtle: {
    color: { default: null, ":is([data-checked])": colorPalette.fg },
    borderColor: { default: null, ":is([data-checked])": colorPalette.solid },
  },
  outline: {
    backgroundColor: { default: null, ":is([data-checked])": colorPalette.solid },
    color: { default: null, ":is([data-checked])": colorPalette.contrast },
    borderColor: { default: null, ":is([data-checked])": colorPalette.solid },
  },
  solid: {
    color: { default: null, ":is([data-checked])": colorPalette.solid },
    borderColor: { default: null, ":is([data-checked])": "currentcolor" },
  },
});

// Root is UI SDK's Checkbox, a <button>: the reset leaves text centered.
const chrome = stylex.create({
  cursorPointer: { cursor: "pointer" },
  textStart: { textAlign: "start" },
  iconFill: { width: "100%", height: "100%" },
});

function CheckIcon() {
  return (
    <svg viewBox="0 0 12 12" fill="none" aria-hidden="true" {...stylex.props(chrome.iconFill)}>
      <path
        d="M2.5 6.4 5 8.9l4.5-5.4"
        stroke="currentColor"
        strokeWidth="2"
        strokeLinecap="round"
        strokeLinejoin="round"
      />
    </svg>
  );
}

function IndicatorNode({
  children,
  ...props
}: React.ComponentProps<typeof UiSdkCheckboxIndicator>) {
  // keepMounted: the card's indicator box shows in both states; the check
  // icon renders from the indicator's own state while checked.
  return (
    <UiSdkCheckboxIndicator keepMounted {...props}>
      {children ?? ((state) => (state.checked ? <CheckIcon /> : null))}
    </UiSdkCheckboxIndicator>
  );
}

const { withProvider, withContext } = createSlotRecipeContext(checkboxCardRecipe);

export type CheckboxCardVariantProps = Partial<SlotRecipeVariants<typeof checkboxCardRecipe>>;

/**
 * Checkbox Card — UI SDK's checkbox styled as a selectable card.
 * `<CheckboxCard.Root variant size>` resolves the recipe once; every part
 * inherits it through context. Root is UI SDK's Checkbox (a
 * `role="checkbox"` button plus a hidden native input for forms) and takes
 * the checked props. UI SDK stamps `data-checked` on both the card and its
 * Indicator, so no mirrored state is needed.
 */
export const CheckboxCard = {
  Root: withProvider(
    UiSdkCheckbox,
    (v) => [
      chrome.textStart,
      ...resolveSlotStyles(checkboxCardRecipe.slots.root, v),
      fromMap(cardChecked, v.variant),
      chrome.cursorPointer,
    ],
    "CheckboxCardRoot",
  ),
  Control: withContext("span", "control", "CheckboxCardControl"),
  Content: withContext("span", "content", "CheckboxCardContent"),
  Label: withContext("span", "label", "CheckboxCardLabel"),
  Description: withContext("span", "description", "CheckboxCardDescription"),
  Indicator: withContext(
    IndicatorNode,
    (v) => [
      ...resolveSlotStyles(checkboxCardRecipe.slots.indicator, v),
      fromMap(cardIndicatorChecked, v.variant),
    ],
    "CheckboxCardIndicator",
  ),
};

export type CheckboxCardRootProps = React.ComponentProps<typeof CheckboxCard.Root>;
export type CheckboxCardControlProps = React.ComponentProps<typeof CheckboxCard.Control>;
export type CheckboxCardContentProps = React.ComponentProps<typeof CheckboxCard.Content>;
export type CheckboxCardLabelProps = React.ComponentProps<typeof CheckboxCard.Label>;
export type CheckboxCardDescriptionProps = React.ComponentProps<typeof CheckboxCard.Description>;
export type CheckboxCardIndicatorProps = React.ComponentProps<typeof CheckboxCard.Indicator>;
```
