# @salmonui/inputs/checkbox API reference

> 7 exported symbols of @salmonui/inputs/checkbox: 2 components, 3 interfaces and 2 types.

Canonical: https://salmonui.dev/docs/reference/inputs/checkbox

```ts
import { … } from '@salmonui/inputs/checkbox';
```

## Components

### Checkbox

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/checkbox/Checkbox

```ts
function Checkbox(props: CheckboxProps): ReactNode;
```

Checkbox on a native `<input type="checkbox">`,
labelled by its children. Inside a `CheckboxGroup` it toggles its `value`
in the group's array. `ref` is the input; unknown props go to the input,
`className` / `style` to the root.

Props: [`CheckboxProps`](https://salmonui.dev/docs/reference/inputs/checkbox/CheckboxProps) (its members are the props)

### CheckboxGroup

Kind: component

Page: https://salmonui.dev/docs/reference/inputs/checkbox/CheckboxGroup

```ts
function CheckboxGroup(props: CheckboxGroupProps): ReactNode;
```

Several checkboxes as one `string[]` value: a `<fieldset>` named
by `label`, with description, error and `required` (at least one).

Props: [`CheckboxGroupProps`](https://salmonui.dev/docs/reference/inputs/checkbox/CheckboxGroupProps) (its members are the props)

## Interfaces

### CheckboxGroupChangeDetails

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/checkbox/CheckboxGroupChangeDetails

```ts
interface CheckboxGroupChangeDetails extends ChoiceChangeDetails<'toggle' | 'reset'> {
    readonly item?: string | undefined;
}
```

Second argument of `CheckboxGroup.onValueChange`; `item` is the toggled checkbox value (absent on reset).

Members (3):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `source: "api" \| PressSource;` | inherited |  |
| `reason` | `reason: "reset" \| "toggle";` | inherited |  |
| `item` | `readonly item?: string \| undefined;` | optional |  |

### CheckboxGroupProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/checkbox/CheckboxGroupProps

```ts
interface CheckboxGroupProps extends FieldCommonProps {
    readonly value?: readonly string[] | undefined;
    readonly defaultValue?: readonly string[] | undefined;
    readonly onValueChange?: ((value: readonly string[], details: CheckboxGroupChangeDetails) => void) | undefined;
    readonly name?: string | undefined;
    readonly form?: string | undefined;
    readonly required?: boolean | undefined;
    readonly disabled?: boolean | undefined;
    readonly orientation?: 'vertical' | 'horizontal' | undefined;
    readonly localeText?: FieldValidationText | undefined;
    readonly id?: string | undefined;
    readonly dir?: 'ltr' | 'rtl' | 'auto' | undefined;
    readonly children?: ReactNode;
    readonly className?: string | undefined;
    readonly style?: CSSProperties | undefined;
    readonly classNames?: {
        readonly label?: string;
        readonly items?: string;
        readonly description?: string;
        readonly error?: string;
    } | undefined;
    readonly ref?: Ref<HTMLFieldSetElement> | undefined;
}
```

Members (23):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `value` | `readonly value?: readonly string[] \| undefined;` | optional |  |
| `defaultValue` | `readonly defaultValue?: readonly string[] \| undefined;` | optional |  |
| `onValueChange` | `readonly onValueChange?: ((value: readonly string[], details: CheckboxGroupChangeDetails) => void) \| undefined;` | optional |  |
| `name` | `readonly name?: string \| undefined;` | optional | Name submitted by every checkbox of the group (one entry per checked value). |
| `form` | `readonly form?: string \| undefined;` | optional |  |
| `required` | `readonly required?: boolean \| undefined;` | optional | At least one checkbox must be checked. |
| `disabled` | `readonly disabled?: boolean \| undefined;` | optional |  |
| `orientation` | `readonly orientation?: 'vertical' \| 'horizontal' \| undefined;` | optional |  |
| `localeText` | `readonly localeText?: FieldValidationText \| undefined;` | optional |  |
| `id` | `readonly id?: string \| undefined;` | optional |  |
| `dir` | `readonly dir?: 'ltr' \| 'rtl' \| 'auto' \| undefined;` | optional |  |
| `children` | `readonly children?: ReactNode;` | optional |  |
| `className` | `readonly className?: string \| undefined;` | optional |  |
| `style` | `readonly style?: CSSProperties \| undefined;` | optional |  |
| `classNames` | `readonly classNames?: {     readonly label?: string;     readonly items?: string;     readonly description?: string;     readonly error?: string; } \| undefined;` | optional | Part classes: `root` is `className`; `label` (legend), `items`, `description`, `error`. |
| `ref` | `readonly ref?: Ref<HTMLFieldSetElement> \| undefined;` | optional | The `<fieldset>`. |
| `label` | `label?: ReactNode;` | optional, inherited |  |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) \| ReactNode;` | optional, inherited | Error text (or a function of the errors) shown while the field is invalid. |
| `invalid` | `invalid?: boolean;` | optional, inherited | Forces the error state. |
| `validation` | `validation?: FieldValidation;` | optional, inherited | Rules in the Data Grid vocabulary. |
| `validateOn` | `validateOn?: ValidateOn;` | optional, inherited | When errors appear; default the `Form`'s, else `'blur'`. |
| `size` | `size?: FieldSize;` | optional, inherited | Metric set. Default `'md'`. |

### CheckboxProps

Kind: interface

Page: https://salmonui.dev/docs/reference/inputs/checkbox/CheckboxProps

```ts
interface CheckboxProps extends ToggleFieldProps {
    readonly indeterminate?: boolean | undefined;
}
```

Members (18):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `checked` | `checked?: boolean;` | optional, inherited |  |
| `defaultChecked` | `defaultChecked?: boolean;` | optional, inherited |  |
| `indeterminate` | `readonly indeterminate?: boolean \| undefined;` | optional | Mixed state: `aria-checked="mixed"` and `data-indeterminate` on the server, the DOM property after mount. |
| `description` | `description?: ReactNode;` | optional, inherited |  |
| `errorMessage` | `errorMessage?: ((ctx: { readonly errors: readonly string[]; }) => ReactNode) \| ReactNode;` | optional, inherited | Error text (or a function of the errors) shown while the field is invalid. |
| `invalid` | `invalid?: boolean;` | optional, inherited | Forces the error state. |
| `validation` | `validation?: FieldValidation;` | optional, inherited | Rules in the Data Grid vocabulary. |
| `validateOn` | `validateOn?: ValidateOn;` | optional, inherited | When errors appear; default the `Form`'s, else `'blur'`. |
| `size` | `size?: FieldSize;` | optional, inherited | Metric set. Default `'md'`. |
| `onCheckedChange` | `onCheckedChange?: ((checked: boolean, details: CheckedChangeDetails) => void);` | optional, inherited |  |
| `value` | `value?: string;` | optional, inherited | Submitted value when checked (native, default `'on'`). |
| `children` | `children?: ReactNode;` | optional, inherited | Label text (rendered in a real `<label for>`). |
| `labelPlacement` | `labelPlacement?: LabelPlacement;` | optional, inherited | Label before (`'start'`) or after (`'end'`, default) the control. |
| `localeText` | `localeText?: FieldValidationText;` | optional, inherited |  |
| `className` | `className?: string;` | optional, inherited |  |
| `style` | `style?: CSSProperties;` | optional, inherited |  |
| `classNames` | `classNames?: { readonly input?: string; readonly label?: string; readonly description?: string; readonly error?: string; };` | optional, inherited | Part classes: `root` is `className`; `input`, `label`, `description`, `error`. |
| `ref` | `ref?: Ref<HTMLInputElement>;` | optional, inherited | The native `<input type="checkbox">`. |

## Types

### CheckedChangeDetails

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/checkbox/CheckedChangeDetails

```ts
type CheckedChangeDetails = ChoiceChangeDetails<'toggle' | 'reset'>;
```

Second argument of `onCheckedChange`: `reason` is `'toggle'` (click, Space) or `'reset'` (form reset).

Members (2):

| Name | Signature | Flags | Description |
| --- | --- | --- | --- |
| `source` | `source: "api" \| PressSource;` | inherited |  |
| `reason` | `reason: "reset" \| "toggle";` | inherited |  |

### LabelPlacement

Kind: type

Page: https://salmonui.dev/docs/reference/inputs/checkbox/LabelPlacement

```ts
type LabelPlacement = 'start' | 'end';
```

Where the label sits relative to the control.
