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

Radio Group

Mutually exclusive options in visually rich cards

How to add this block to your project
npm create webcore@latest add RadioGroup
Need to add a simple radio without cards? Use the Radio component.

Use the RadioGroup component to display mutually exclusive options as visually rich cards with radio buttons, icons, labels, and supporting text. They:

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

The component must have the following props:

Listening to Events

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

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

This will emit an object containing the name of the radio group and the value of the selected item. 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
Extended updates
Get notified about updates & breaking changes
All updates
Get notified about all updates, including application errors
How to set the number of columns
<RadioGroup
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
Extended updates
Get notified about updates & breaking changes
All updates
Get notified about all updates, including application errors
Primary style
Updates
Get notified about updates
Extended updates
Get notified about updates & breaking changes
All updates
Get notified about all updates, including application errors
How to change card style
<RadioGroup
items={items}
name="columns"
columns={2}
flat={false}
secondary={false}
/>

API

Component API reference
type RadioGroupProps = {
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.