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
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
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
Current value: null
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
itemsreqListItem[]Array of state items to cycle through. Each item has value, label, and optional icon
itemsreqListItem[]Array of state items to cycle through. Each item has value, label, and optional icon
valueanyCurrent value of the checkbox (controlled component)
valueanyCurrent value of the checkbox (controlled component)
onChange(event: ComponentEvent<T>) => voidChange event handler. Receives event object with value, name, and args properties
onChange(event: ComponentEvent<T>) => voidChange event handler. Receives event object with value, name, and args properties
requiredboolean"false"Mark the hidden input as required for form validation
requiredboolean"false"Mark the hidden input as required for form validation
disabledboolean"false"Disable the checkbox interaction
disabledboolean"false"Disable the checkbox interaction
idstringHTML id attribute for the button element
idstringHTML id attribute for the button element
namestringName attribute for the hidden input (used in forms)
namestringName attribute for the hidden input (used in forms)
argsanyAdditional arguments passed to onChange handler
argsanyAdditional arguments passed to onChange handler
classNamestringAdditional CSS classes for the container
classNamestringAdditional 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