Radio Card
<afp-radio-card>
The Radio Card component allows users to select a single option from a set of choices. It is typically used in groups where only one radio card button can be selected at a time.
Examples #
Variants #
Use the variant attribute to set the radio card's variant.
Sizes #
Use the size attribute to change the radios size
No Indicator #
Use the noIndicator (noindicator) attribute to determine whether the radio check should be displayed.
Hint #
Use the hint attribute to provide additional information below the radio card.
Checked #
Use the checked attribute to render a radio card in the checked state.
Disabled #
Use the disabled attribute to make a radio card unselectable.
Invalid #
Use the invalid attribute to display an error message and style the radio card accordingly.
Properties
Learn more about properties.
| Name | Description | Reflects | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
variant
|
variant of radio card
Type
AfpVariant
Default
AfpVariant.NEUTRAL |
|
||||||||||||||||
noIndicator
noindicator
|
determines whether the radio card check indicator should be visible
Type
boolean
Default
false |
|
||||||||||||||||
checked
|
Whether the radio card is checked
Type
boolean
Default
false |
|
||||||||||||||||
value
|
The value associated with the radio card
Type
string
|
|||||||||||||||||
group
|
The group name (shared among radio cards)
Type
string
|
|||||||||||||||||
disabled
|
Whether the radio card is disabled
Type
boolean
Default
false |
|
||||||||||||||||
size
|
Size of the radio card
Type
AfpSize
Default
AfpSize.MEDIUM |
|
||||||||||||||||
invalid
|
Error message shown below the radio card when present. Sets `aria-invalid`. Provide a non-empty string to put the component in an error state
Type
string
|
|||||||||||||||||
hint
|
Optional hint message below the radio card
Type
string
Default
'' |
Events
Learn more about events.
| Name | Return | Description |
|---|---|---|
afp-value-changed
|
{ value: number | string | undefined; checked: boolean }
|
Fired when the radio card is selected.
|
afp-focus
|
void
|
Fired when the radio card gains focus.
|
afp-blur
|
void
|
Fired when the radio card loses focus.
|
afp-change
|
string
|
Fired when the checked state changes.
|
Slots
Learn more about slots.
| Name | Description |
|---|---|
default
|
The label content of the radio card button.
|
checked-icon
|
The icon to display inside the selected radio card.
|
Internationalization
Learn more about internationalization.
| Key | Description |
|---|---|
radio-card.aria-label
|
The default `aria-label` text for radio card.
|
CSS Parts
Learn more about CSS Parts.
| Name | Description | Selector |
|---|---|---|
base
|
The outer wrapper of the radio.
|
::part(base)
|
input
|
The internal `<input>` element.
|
::part(input)
|
control
|
The visual control (the circle).
|
::part(control)
|
checked-icon
|
The icon shown when the radio is checked.
|
::part(checked-icon)
|
invalid
|
The error message text.
|
::part(invalid)
|
hint
|
The hint message text.
|
::part(hint)
|
content
|
The content of the radio card.
|
::part(content)
|
label
|
The text label next to the control.
|
::part(label)
|
CSS Custom Properties
| Name | Description | Default |
|---|---|---|
--afp-radio-card-tranform-scale
|
The scale transform of the radio card from unchecked to checked.
|
0.8
|
--afp-radio-card-disabled-opacity
|
The opacity of the radio card when disabled.
|
0.5
|
--afp-radio-card-color
|
The color of the radio card when checked.
|
--afp-color-neutral-fill-loud
|
--afp-radio-card-checked-shadow
|
The shadow and its color displayed on the card when the radio card is selected.
|
0 0 0 1px var(--variant-color-fill)
|
--afp-radio-card-padding
|
The padding inside the radio card.
|
--afp-space-m
|
--afp-input-error-border-color
|
The border color of the radio card in the invalid/error state.
|
--afp-color-error-500
|
Dependencies
The component automatically brings in the listed items, including any nested dependencies that may exist.
Importing
Using the bundle is the recommended method to include components. If you’d rather handle imports manually, you can use the code examples below.
import '@afp-design-system/core/dist/components/radio-card/radio-card.js';