Brutalist Checkbox Group
Manage a string array of selected checkboxes with select-all support, horizontal layout, and Field/Form integration.
Brutalist Checkbox Group coordinates a set of checkboxes backed by a string array, with select-all/mixed state, vertical or horizontal layout, square 2px borders, DM Sans 500 label typography, and high-contrast focus rings.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-brutalist-checkbox-group-root id="brutalist-cg-hero">
<proto-ui-brutalist-checkbox-group-all>
All notifications
</proto-ui-brutalist-checkbox-group-all>
<proto-ui-brutalist-checkbox-group-item>
Email updates
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
SMS alerts
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
Push notifications (unavailable)
</proto-ui-brutalist-checkbox-group-item>
</proto-ui-brutalist-checkbox-group-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#brutalist-cg-hero');
setElementProps(root, {
defaultValue: ['email'],
ariaLabel: 'Notification channels',
});
const items = root.querySelectorAll(
'proto-ui-brutalist-checkbox-group-item'
);
setElementProps(items[0], { value: 'email' });
setElementProps(items[1], { value: 'sms' });
setElementProps(items[2], { value: 'push', disabled: true });
</script>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
import { BrutalistCheckboxGroupRoot, BrutalistCheckboxGroupAll, BrutalistCheckboxGroupItem,} from '../proto-ui/components/react';
export function Example() { return ( <BrutalistCheckboxGroupRoot defaultValue={['email']} ariaLabel="Notification channels"> <BrutalistCheckboxGroupAll>All notifications</BrutalistCheckboxGroupAll> <BrutalistCheckboxGroupItem value="email">Email updates</BrutalistCheckboxGroupItem> <BrutalistCheckboxGroupItem value="sms">SMS alerts</BrutalistCheckboxGroupItem> </BrutalistCheckboxGroupRoot> );}Anatomy and keyboard
Section titled “Anatomy and keyboard”- Root: Manages the selected
string[]value (value/defaultValue),orientation,disabled,readOnly, andariaLabel. - Item: Individual option with a unique
valueand optionaldisabledflag. Each enabled option has its ownTabstop and toggles withSpace(Enterdoes not toggle). - All: Derives checked, mixed (
aria-checked="mixed"), or unchecked state across enabled items and toggles only enabled items while preserving disabled selections. - Accessibility and forms: The square 20×20 indicator box renders check/dash glyphs and owns the focus ring; inside
FieldorFormField,Rootparticipates in label activation, required validation, serialization, and reset.
Examples
Section titled “Examples” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-brutalist-checkbox-group-root id="brutalist-cg-basic">
<proto-ui-brutalist-checkbox-group-item>
Recents
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
Home
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
Applications
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
Desktop
</proto-ui-brutalist-checkbox-group-item>
</proto-ui-brutalist-checkbox-group-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#brutalist-cg-basic');
setElementProps(root, {
defaultValue: ['recents', 'home'],
ariaLabel: 'Sidebar items',
});
const values = ['recents', 'home', 'applications', 'desktop'];
root
.querySelectorAll('proto-ui-brutalist-checkbox-group-item')
.forEach((item, index) => {
setElementProps(item, { value: values[index] });
});
</script>Horizontal
Section titled “Horizontal” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-brutalist-checkbox-group-root
id="brutalist-cg-horizontal"
>
<proto-ui-brutalist-checkbox-group-item>
Email
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
SMS
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
In-app
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
Weekly digest
</proto-ui-brutalist-checkbox-group-item>
</proto-ui-brutalist-checkbox-group-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#brutalist-cg-horizontal');
setElementProps(root, {
defaultValue: ['email', 'in-app'],
orientation: 'horizontal',
ariaLabel: 'Delivery channels',
});
const values = ['email', 'sms', 'in-app', 'digest'];
root
.querySelectorAll('proto-ui-brutalist-checkbox-group-item')
.forEach((item, index) => {
setElementProps(item, { value: values[index] });
});
</script>Disabled and Read-Only
Section titled “Disabled and Read-Only” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="grid gap-4">
<proto-ui-brutalist-checkbox-group-root
id="brutalist-cg-disabled"
>
<proto-ui-brutalist-checkbox-group-item>
Email
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
SMS
</proto-ui-brutalist-checkbox-group-item>
</proto-ui-brutalist-checkbox-group-root>
<proto-ui-brutalist-checkbox-group-root
id="brutalist-cg-readonly"
>
<proto-ui-brutalist-checkbox-group-item>
Email
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
SMS
</proto-ui-brutalist-checkbox-group-item>
</proto-ui-brutalist-checkbox-group-root>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const disabledRoot = document.querySelector(
'#brutalist-cg-disabled'
);
setElementProps(disabledRoot, {
defaultValue: ['email'],
disabled: true,
ariaLabel: 'Disabled channels',
});
const readOnlyRoot = document.querySelector(
'#brutalist-cg-readonly'
);
setElementProps(readOnlyRoot, {
defaultValue: ['email'],
readOnly: true,
ariaLabel: 'Read-only channels',
});
for (const group of [disabledRoot, readOnlyRoot]) {
const items = group.querySelectorAll(
'proto-ui-brutalist-checkbox-group-item'
);
setElementProps(items[0], { value: 'email' });
setElementProps(items[1], { value: 'sms' });
}
</script>Controlled
Section titled “Controlled” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<div class="grid gap-3">
<proto-ui-brutalist-checkbox-group-root
id="brutalist-cg-controlled"
>
<proto-ui-brutalist-checkbox-group-all>
All channels
</proto-ui-brutalist-checkbox-group-all>
<proto-ui-brutalist-checkbox-group-item>
Email
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
SMS
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
Webhook
</proto-ui-brutalist-checkbox-group-item>
</proto-ui-brutalist-checkbox-group-root>
<div id="brutalist-cg-status" role="status" aria-live="polite">
Selected: email
</div>
</div>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#brutalist-cg-controlled');
const status = document.querySelector('#brutalist-cg-status');
const values = ['email', 'sms', 'webhook'];
root
.querySelectorAll('proto-ui-brutalist-checkbox-group-item')
.forEach((item, index) => {
setElementProps(item, { value: values[index] });
});
let selected = ['email'];
const sync = () => {
setElementProps(root, {
value: selected,
ariaLabel: 'Release channels',
});
status.textContent = selected.length
? 'Selected: ' + selected.join(', ')
: 'Selected: none';
};
root.addEventListener('valueChange', (event) => {
selected = [...event.detail.value];
sync();
});
sync();
</script>Form Validation
Section titled “Form Validation” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
<proto-ui-brutalist-form-root id="brutalist-cg-form">
<proto-ui-brutalist-form-field id="brutalist-cg-field">
<proto-ui-brutalist-field-label>
Notification channels
</proto-ui-brutalist-field-label>
<proto-ui-brutalist-checkbox-group-root
id="brutalist-cg-form-group"
>
<proto-ui-brutalist-checkbox-group-item>
Email
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
SMS
</proto-ui-brutalist-checkbox-group-item>
<proto-ui-brutalist-checkbox-group-item>
In-app
</proto-ui-brutalist-checkbox-group-item>
</proto-ui-brutalist-checkbox-group-root>
<proto-ui-brutalist-field-error></proto-ui-brutalist-field-error>
</proto-ui-brutalist-form-field>
<div class="flex gap-2">
<proto-ui-brutalist-form-submit>
Save preferences
</proto-ui-brutalist-form-submit>
<proto-ui-brutalist-form-reset>
Reset
</proto-ui-brutalist-form-reset>
</div>
</proto-ui-brutalist-form-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const form = document.querySelector('#brutalist-cg-form');
const field = document.querySelector('#brutalist-cg-field');
const group = document.querySelector('#brutalist-cg-form-group');
setElementProps(form, { ariaLabel: 'Notification preferences' });
setElementProps(field, { name: 'channels', required: true });
setElementProps(group, { defaultValue: ['email'] });
const values = ['email', 'sms', 'in-app'];
group
.querySelectorAll('proto-ui-brutalist-checkbox-group-item')
.forEach((item, index) => {
setElementProps(item, { value: values[index] });
});
</script>| Prop | Type | Default |
|---|---|---|
value | string[] undefined | Uncontrolled |
defaultValue | string[] | [] |
orientation | 'vertical' 'horizontal' | 'vertical' |
disabled | boolean | false |
readOnly | boolean | false |
ariaLabel | string | '' |
| Prop | Type | Default |
|---|---|---|
value | string | '' |
disabled | boolean | false |
| Prop | Type | Default |
|---|---|---|
disabled | boolean | false |
Events, Methods, and States
Section titled “Events, Methods, and States”- Root events:
valueChange(payload{ value: string[] }). - Root methods:
getValue(): string[],resetValue(): boolean,focusSelf(): void. - Exposed states: Root exposes
checked,indeterminate,disabled,readOnly; Item and All exposechecked,indeterminate,disabled,readOnly,focused,focusVisible.