🚀 Ship faster with premium components 🚀
Search documentation v1.5.0

Checkbox Group

Multiple select options in visually rich cards

How to add this block to your project
npm create webcore@latest add CheckboxGroup
Need to add a simple checkbox? Use the Checkbox component.

Use the CheckboxGroup component to present multiple selectable options as visually rich cards with icons, labels, and supporting text. They:

Preview
Updates
Get notified about updates
Breaking Changes
Get notified about breaking changes
Application errors
Get alerts about application errors
How to use the CheckboxGroup component in Astro
---
import { info } from 'webcoreui/icons'
const items = [
{
icon: info,
label: 'Updates',
subText: 'Get notified about updates',
value: 'info',
checked: true
}, { ... }, { ... }
]
---
<CheckboxGroup
items={items}
name="preview"
/>

The component must have the following props:

Listening to Events

To trigger actions when a checkbox group is changed, you can listen to the checkboxGroupOnChange event:

How to listen to change events
<script>
import { listen } from 'webcoreui'
listen('checkboxGroupOnChange', event => {
console.log(event)
})
</script>

This will emit an object containing the name of the checkbox group and the value of the checked items. Using Svelte/React variants, you can use the onChange prop instead.

Number of Columns

By default, the component uses a 1 column layout. You can set the number of columns using the columns prop.

2-column layout
Updates
Get notified about updates
Breaking Changes
Get notified about breaking changes
Application errors
Get alerts about application errors
How to set the number of columns
<CheckboxGroup
items={items}
name="columns"
columns={2}
/>

Card Styles

The component uses the Card component under the hood. This means you can tweak the appearance using card-specific props, such as secondary, compact, or flat.

Flat disabled
Updates
Get notified about updates
Breaking Changes
Get notified about breaking changes
Application errors
Get alerts about application errors
Primary style
Updates
Get notified about updates
Breaking Changes
Get notified about breaking changes
Application errors
Get alerts about application errors
How to change card style
<CheckboxGroup
items={items}
name="columns"
columns={2}
flat={false}
secondary={false}
/>

API

Component API reference
type CheckboxGroupProps = {
items: {
icon?: string
label: string
subText?: string
value: string
checked?: boolean
disabled?: boolean
}[]
name: string
columns?: 1 | 2 | 3 | 4
className?: string
} & CardProps
PropPurpose
items Sets the items to display.
items.icon Sets an optional icon for the item.
items.label Sets the label for the item.
items.subText Sets an optional subtext for the item.
items.value Sets the value for the item that is emitted on change.
items.checked Sets the item as checked by default.
items.disabled Sets the item as disabled by default.
name Sets the name for the input group.
columns Sets the number of columns. Defaults to 1.
className Pass additional CSS classes for the component.