Astryx

Astryx Checkbox Input

Forms

About

CheckboxInput toggles a single on/off value. Use it for settings like "Enable notifications", terms acceptance, or opt-in choices. For multiple checkboxes in a group, use CheckboxList instead.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Astryx Checkbox Input to your project and fits it to your theme.

Code

How Astryx Checkbox Input is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

'use client';

import {useState} from 'react';
import {CheckboxInput} from '@/components/ui/astryx-checkbox-input';
import {Stack} from '@astryxdesign/core/Layout';
import {Divider} from '@astryxdesign/core/Divider';

function CheckboxInputIndeterminateState() {
  const [items, setItems] = useState({
    email: true,
    push: false,
    sms: true,
    slack: false,
  });

  const checkedCount = Object.values(items).filter(Boolean).length;
  const totalCount = Object.keys(items).length;
  const selectAllValue =
    checkedCount === 0
      ? false
      : checkedCount === totalCount
        ? true
        : ('indeterminate' as const);

  const handleSelectAll = (checked: boolean) => {
    setItems({email: checked, push: checked, sms: checked, slack: checked});
  };

  return (
    <Stack direction="vertical" gap={3}>
      <CheckboxInput
        label="Select all notifications"
        description={`${checkedCount} of ${totalCount} enabled`}
        value={selectAllValue}
        onChange={handleSelectAll}
      />
      <Divider />
      <Stack direction="vertical" gap={3}>
        <CheckboxInput
          label="Email notifications"
          value={items.email}
          onChange={v => setItems(prev => ({...prev, email: v}))}
        />
        <CheckboxInput
          label="Push notifications"
          value={items.push}
          onChange={v => setItems(prev => ({...prev, push: v}))}
        />
        <CheckboxInput
          label="SMS alerts"
          value={items.sms}
          onChange={v => setItems(prev => ({...prev, sms: v}))}
        />
        <CheckboxInput
          label="Slack messages"
          value={items.slack}
          onChange={v => setItems(prev => ({...prev, slack: v}))}
        />
      </Stack>
    </Stack>
  );
}

export default function CheckboxInputIndeterminateStateDemo() {
  return (
    <div
      data-astryx-theme="neutral"
      data-theme="light"
      style={{colorScheme: 'light', display: 'contents'}}>
      <CheckboxInputIndeterminateState />
    </div>
  );
}

Dependencies

More by Astryx

View all
  • Astryx Banner

    Astryx Banner

    61
  • Astryx Avatar

    Astryx Avatar

    34
  • Astryx Aspect Ratio

    Astryx Aspect Ratio

    32
  • Astryx Badge

    Astryx Badge

    30
  • Astryx Button Group

    Astryx Button Group

    29
  • Astryx Chat Composer Drawer

    Astryx Chat Composer Drawer

    25
  • Astryx Toggle Button

    Astryx Toggle Button

    17
  • Astryx Avatar Group

    Astryx Avatar Group

    10

More in Forms

View all
  • Premium Auth

    Premium Auth

    600
  • Contact Form

    Contact Form

    28
  • Form

    Form

    6
  • Contact Card

    Contact Card

    1.1K
  • Login 1

    Login 1

    70
  • Book A Demo 1

    Book A Demo 1

    95
  • Input

    Input

    14
  • Book A Demo 4

    Book A Demo 4

    69