A wrapper for OptionCard components.
In a React app, the component can be imported via:
In an Ember app, the component is named PlumaOptionCardGroup.
An OptionCardGroup should contain OptionCard components as children. OptionCardGroup
will forward the name attribute to any Checkboxes nested within, as well as
connect onChange handlers to them, so there's no need to define those props
on the OptionCards themselves:
Or, in Ember:
An OptionCardGroup must always have an associated label. The component accepts a label
string prop, which renders text above the nested checkboxes.
Alternatively, ariaLabelledby may be used to associate the group with a label
elsewhere in the DOM. To make sure the association is set up both ways, it's recommended
to also set for on the label, pointing to an id on the checkbox group:
Finally, the ariaLabel prop can be used if no other element is suitable for
a label.
The isDisabled prop on an OptionCardGroup will take precedence over the isDisabled
prop on individual OptionCard components.
It is not necessary to set isDisabled on the individual OptionCard components, as
the OptionCardGroup provides that state to the cards through its context.
An inputType can be set o the OptionCardGroup, which will be passed down into
the nested OptionCards:
Just like in the OptionCard component,
selection can be prevented with the canSelect prop.
Note that deselecting is still allowed.
This is useful in cases where you need to limit a checkbox-based selection to a maximum number of options.
The Option Card Group component accepts a size prop that controls the size of all option cards within the group. This allows you to easily set a consistent size for all cards in the group without having to specify it on each individual card.
The size property accepts either "md" (default) or "sm" as values.
By default, the cards will render in a flex container, with a gap of 200 and no wrapping.
The layout of the card container can be customized through the following properties:
For example:
PlumaOptionCardGroup extends BoxThe aria-label attribute to be applied on the fieldset
The aria-labelledby attribute to be applied on the fieldset
This option prevents selection of cards.
Unlike isDisabled, however, it will not prevent the deselection of currently selected cards.
The align-items style of the card container
Default:row
The flex-direction style of the card container
The justify-content style of the card container
An optional id attribute to assign to the fieldset
Default:radio
Whether the cards in the group represent radio or checkbox inputs.
Whether the entire group is disabled
The label text to be shown above the option card group
The name shared by option cards in this group. If none is provided, one will be generated
Called when the value changes
Default:false
Whether the cards should wrap (sets flex-wrap to wrap or nowrap)
Default:md
The size of all option cards in the group
The current value.
If the inputType is radio, the value is a string. When the inputType is checkbox, the value is an array of strings.