Anex UI logoAnex UI
npm install anexui
Documentation

Documentation

Checkbox

A checkbox with optional label, indeterminate state, and full keyboard support.

Preview

Usage

import { Checkbox } from "anexui";

<Checkbox label="Accept terms and conditions" />
Copy code

Controlled

import { useState } from "react";
import { Checkbox } from "anexui";

function Example() {
  const [checked, setChecked] = useState(false);
  return (
    <Checkbox
      label="Subscribe to newsletter"
      checked={checked}
      onChange={(e) => setChecked(e.target.checked)}
    />
  );
}
Copy code

Indeterminate

<Checkbox label="Select all" indeterminate />
Copy code

Disabled

<Checkbox label="Disabled option" disabled />
<Checkbox label="Disabled checked" disabled defaultChecked />
Copy code

Group with fieldset

<fieldset>
  <legend>Notifications</legend>
  <Checkbox label="Email" defaultChecked />
  <Checkbox label="SMS" />
  <Checkbox label="Push" />
</fieldset>
Copy code

Props

| Prop | Type | Default | Description | |---|---|---|---| | label | string | — | Visible text label — wraps in an accessible <label> | | indeterminate | boolean | false | Sets the mixed (indeterminate) state | | checked | boolean | — | Controlled checked state | | defaultChecked | boolean | — | Uncontrolled initial state | | disabled | boolean | false | Disables the checkbox | | onChange | ChangeEventHandler | — | Change handler |

The type prop is fixed to "checkbox" and cannot be overridden. All other standard <input> attributes are accepted.

Accessibility