Checkbox Card

A checkbox laid out as a card, with room for a title, a description, and an icon.

Usage

Code
import { CheckboxCard } from '@leverui/components';
Code
<CheckboxCard.Root>
  <CheckboxCard.HiddenInput />
  <CheckboxCard.Control>
    <CheckboxCard.Content>
      <CheckboxCard.Label />
      <CheckboxCard.Description />
    </CheckboxCard.Content>
    <CheckboxCard.Indicator />
  </CheckboxCard.Control>
</CheckboxCard.Root>

For one component with props, see the snippet below.

Examples

Description

Use the CheckboxCard.Description component to add a description to the checkbox card.

Group

Use the CheckboxGroup component to group multiple checkbox cards.

Select frameworks

Sizes

Pass the size prop to the CheckboxCard.Root component to change the size of the checkbox card.

Variants

Pass the variant prop to the CheckboxCard.Root component to change the variant of the checkbox card.

Disabled

Pass the disabled prop to the CheckboxCard.Root component to make the checkbox card disabled.

Addon

Render additional content within the CheckboxCard.Addon component to add some more context to the checkbox card.

No Indicator

Here's an example of how to use the checkbox card without an indicator.

Icon

Here's an example of how to render custom icons within the checkbox card.

Closed Component

Code
import { Show, omit } from 'solid-js';
import type { JSX } from '@solidjs/web';
import { CheckboxCard, type CheckboxCardRootProps } from '@leverui/components';

export type ClosedCheckboxCardProps = CheckboxCardRootProps & {
  icon?: JSX.Element;
  label?: JSX.Element;
  description?: JSX.Element;
  addon?: JSX.Element;
  indicatorPlacement?: 'start' | 'end' | 'inside' | undefined;
};

export function ClosedCheckboxCard(props: ClosedCheckboxCardProps) {
  const root = omit(props, 'icon', 'label', 'description', 'addon', 'indicatorPlacement');
  const placement = () => props.indicatorPlacement ?? 'end';

  return (
    <CheckboxCard.Root {...root}>
      <CheckboxCard.HiddenInput />
      <CheckboxCard.Control>
        <Show when={placement() === 'start'}>
          <CheckboxCard.Indicator />
        </Show>
        <CheckboxCard.Content>
          {props.icon}
          <Show when={props.label}>
            <CheckboxCard.Label>{props.label}</CheckboxCard.Label>
          </Show>
          <Show when={props.description}>
            <CheckboxCard.Description>{props.description}</CheckboxCard.Description>
          </Show>
          <Show when={placement() === 'inside'}>
            <CheckboxCard.Indicator />
          </Show>
        </CheckboxCard.Content>
        <Show when={placement() === 'end'}>
          <CheckboxCard.Indicator />
        </Show>
      </CheckboxCard.Control>
      <Show when={props.addon}>
        <CheckboxCard.Addon>{props.addon}</CheckboxCard.Addon>
      </Show>
    </CheckboxCard.Root>
  );
}
Code
<ClosedCheckboxCard label="Checkbox Card" />

Guides

CheckboxGroup + Field vs Fieldset

  • Single CheckboxCard: wrap in Field.Root for a label and helper text.
  • CheckboxGroup: wrap in Fieldset.Root with a legend, not Field.Root.

Correct usage:

Code
<Fieldset.Root>
  <CheckboxGroup name="framework">
    <Fieldset.Legend>Select frameworks</Fieldset.Legend>
    {/* ... checkbox cards ... */}
  </CheckboxGroup>
</Fieldset.Root>

Incorrect usage:

Code
// Don't wrap CheckboxGroup with Field.Root
<Field.Root>
  <CheckboxGroup>{/* ... checkbox cards ... */}</CheckboxGroup>
</Field.Root>

Props

Root

PropDefaultTypeDescription
valueonstringValue sent with the form.
colorPalettegraystringColor palette, built-in or your own.
sizemd'sm' | 'md' | 'lg'Card size.
variantoutline'surface' | 'subtle' | 'outline' | 'solid'Card style.
alignstart'start' | 'end' | 'center'Content alignment.
orientationhorizontal'vertical' | 'horizontal'Lay content out in a row or a column.
aslabelNative HTML tagHTML tag to render.
asChild—Solid render functionRender your own element with the card's props.
unstyledfalsebooleanTurn off the Lever UI styles.
checked—CheckedStateChecked state, when you control it.
defaultChecked—CheckedStateChecked state on first render.
disabled—booleanDisable the checkbox.
form—stringID of the form the checkbox belongs to.
id—stringUnique ID for the checkbox.
ids—Element ID mapYour own IDs in place of the generated ones.
invalid—booleanMark the checkbox as invalid.
name—stringName submitted with the form.
onCheckedChange—(details) => voidCalled when the checked state changes.
readOnly—booleanMake the checkbox read-only.
required—booleanMark the checkbox as required.
justify—'start' | 'end' | 'center'Content justification.

Keep HiddenInput in each card. It handles focus, validation, the accessible label, and form submission.

Explorer

Click a part name to highlight it in the preview.

Component Anatomy

Hover to highlight, click to select parts