Fluxo UIFluxo UIv0.4.1

MultiStateCheckbox

A checkbox-style component that cycles through multiple predefined states on each click, with support for custom icons and labels.

Basic Usage

Basic MultiStateCheckbox

Current value: null

Basic Example
import { MultiStateCheckbox } from 'fluxo-ui';

const states = [
  { value: null, label: 'No Selection', icon: undefined },
  { value: 'yes', label: 'Yes', icon: CheckIcon },
  { value: 'no', label: 'No', icon: MinusIcon },
];

function MyComponent() {
  const [value, setValue] = useState(null);

  return (
    <MultiStateCheckbox
      items={states}
      value={value}
      onChange={(e) => setValue(e.value)}
    />
  );
}

Custom States

Custom State Configurations

Priority Selector (3 states)
Approval Workflow (4 states)
Custom States Example
import { MultiStateCheckbox } from 'fluxo-ui';
import { InfoIcon, WarningIcon, FlagIcon, CheckIcon, MinusIcon } from 'fluxo-ui/icons';

const priorityStates = [
  { value: null, label: 'No Priority', icon: undefined },
  { value: 'low', label: 'Low', icon: InfoIcon },
  { value: 'medium', label: 'Medium', icon: WarningIcon },
  { value: 'high', label: 'High', icon: FlagIcon },
];

const approvalStates = [
  { value: 'pending', label: 'Pending', icon: InfoIcon },
  { value: 'approved', label: 'Approved', icon: CheckIcon },
  { value: 'rejected', label: 'Rejected', icon: MinusIcon },
  { value: 'flagged', label: 'Flagged', icon: FlagIcon },
];

function MyComponent() {
  const [priority, setPriority] = useState(null);
  const [approval, setApproval] = useState('pending');

  return (
    <>
      <MultiStateCheckbox
        items={priorityStates}
        value={priority}
        onChange={(e) => setPriority(e.value)}
      />
      <MultiStateCheckbox
        items={approvalStates}
        value={approval}
        onChange={(e) => setApproval(e.value)}
      />
    </>
  );
}

Controlled & Disabled

Controlled & Disabled States

Controlled

Current value: null

Disabled
Controlled & Disabled Example
import { MultiStateCheckbox, Button } from 'fluxo-ui';

function MyComponent() {
  const [value, setValue] = useState(null);

  return (
    <div>
      <MultiStateCheckbox
        items={states}
        value={value}
        onChange={(e) => setValue(e.value)}
      />
      <Button label="Reset" onClick={() => setValue(null)} />
      <MultiStateCheckbox
        items={states}
        value={value}
        disabled
      />
    </div>
  );
}

Import

import { MultiStateCheckbox } from 'fluxo-ui';

Props

itemsreq
ListItem[]

Array of state items to cycle through. Each item has value, label, and optional icon

value
any

Current value of the checkbox (controlled component)

onChange
(event: ComponentEvent<T>) => void

Change event handler. Receives event object with value, name, and args properties

required
boolean"false"

Mark the hidden input as required for form validation

disabled
boolean"false"

Disable the checkbox interaction

id
string

HTML id attribute for the button element

name
string

Name attribute for the hidden input (used in forms)

args
any

Additional arguments passed to onChange handler

className
string

Additional CSS classes for the container

Features

Multiple States

Cycle through any number of custom states with a single click

Custom Icons

Each state can display a unique icon to visually indicate its meaning

Controlled

Fully controlled value state via the value and onChange props

Keyboard Accessible

Supports Space and Enter keys for cycling through states

Form Integration

Hidden input with name attribute for seamless form submission

Theming

Full dark/light mode and brand theme support via CSS variables