AsterUIDocsv1.0.2

Docs / Component reference

Checkbox, CheckboxGroup & RadioGroup

Use checkboxes for independent choices. The same module supplies a radio group for choices where only one answer fits.

Checkbox example

Install

sh
npx @fierst/ui@1.0.2 add checkbox

Registry dependencies: theme, icon. Package dependencies: @lucide/icons.

Exports from ./ui/checkbox: Checkbox, ChoiceOption, CheckboxGroup, RadioGroup.

Download the registry source for checkbox 1.0.2.

API contracts

ts
export function* Checkbox(
  props: {
    checked?: boolean;
    defaultChecked?: boolean;
    indeterminate?: boolean;
    label?: string;
    description?: string;
    disabled?: boolean;
    card?: boolean;
    name?: string;
    value?: string;
    onChange?: (checked: boolean) => void;
    class?: string;
  },
  ctx: Ctx,
)

export interface ChoiceOption {
  value: string;
  label: string;
  description?: string;
  disabled?: boolean;
}

export function* CheckboxGroup(
  props: {
    legend?: string;
    options: readonly ChoiceOption[];
    value?: readonly string[];
    defaultValue?: readonly string[];
    card?: boolean;
    orientation?: 'vertical' | 'horizontal';
    onChange?: (values: string[]) => void;
    class?: string;
  },
  ctx: Ctx,
)

export function* RadioGroup(
  props: {
    legend?: string;
    name?: string;
    options: readonly ChoiceOption[];
    value?: string;
    defaultValue?: string;
    card?: boolean;
    orientation?: 'vertical' | 'horizontal';
    onChange?: (value: string) => void;
    class?: string;
  },
  ctx: Ctx,
)