A radio or checkbox input wrapped in a card. It can be used anywhere you would use radio or checkbox inputs, where users are asked to make a choice from a number of options. The OptionCard, however, renders a more visually prominent card, with an increased click area, compared to a standard radio or checkbox.
Usually this component should be used with the OptionCardGroup component.
The component can be imported via:
When using a standalone OptionCard, at a minimum you will need to supply:
isSelected stateonCheckedChange or onChange)titleinputType (this defaults to radio)You can also customize the option card with:
size of sm or md (defaults to md)layout of horizontal or vertical (when using with an icon)icon property for visual contextMore examples of available props:
An OptionCard must always include a title and/or description. The content will render
inside the card, and there is no distinction between a "label" and a "description",
from an accessibility point of view, due to the card's layout (the whole card is a <label> tag).
Titles and descriptions can be provided via the title and description props:
An icon can be rendered inside the card to provide additional visual context.
This can be done with the icon prop, which accepts a Pluma Icon name.
When an icon is present, OptionCard can be rendered in a horizontal or vertical layout,
which can be changed via the layout prop:
OptionCard can be rendered in two sizes: sm (small) and md (medium, default).
The size can be changed via the size prop:
If you need to render custom content in a card (when string title and description props aren't enough),
you can the content into the OptionCard component in block form:
You may also use the card's title and description components, if you want to render custom content but still use the card's styles.
You can prevent cards from being selected, but still allow deselecting them,
with the canSelect prop. This is different from the isDisabled prop, which
disabled selections and deselections entirely.
This is useful in cases where you need to limit a checkbox-based selection to a maximum number of options.
PlumaOptionCard extends BoxElement (or elements) that describe the form field. Also used for error messages, as aria-errormessage isn't supported in all assistive technologies: https://a11ysupport.io/tech/aria/aria-errormessage_attribute
String value that labels the form field.
Element (or elements) that label the form field.
This option prevents selection of the card.
Unlike isDisabled, however, it will not prevent the deselection, if currently selected.
An additional description to be shown in the card.
An error message associated with the form field.
Boolean: Ember-only. If the error named block is used,
this prop can be set to true to indicate an error is present,
which will make the error block render.
The name of an icon (from Pluma Icons) to render in the card.
The source URL of a custom image icon to render in the card. When provided, this will be rendered using the Image component with icon sizing. The image will always have alt="" as it is purely decorative - meaning comes from card title or aria-label.
An optional id to be assigned to the input element. Also used to generate ids for labels and error messages. If one isn't provided, it will be generated.
Default:radio
Whether the card represents a radio or a checkbox input.
Whether the form field is disabled.
Whether the form field is in an invalid state.
Whether the card is in the "selected" state.
Default:horizontal
Controls the layout and text alignment of the card. In horizontal layout, content is left-aligned;
in vertical layout, content is centered. When an icon or iconSrc is present, also controls
the position of the icon relative to the card content.
The name shared by cards in the same group.
The change event handler for the input element.
Fired when a card is selected or deselected. Exact behavior depends on whether it's a checkbox or a radio.
In React, the event is a React SyntheticEvent; in Ember it's a native change event.
Callback fired when the state of the option card changes.
Whether to allow browser autofill and password managers. When false (default), adds attributes to disable password managers (1Password, LastPass, Bitwarden, Dashlane). Set to true for fields where autofill is desired (e.g., email, password, address fields).
Whether the generated description id should be included in the input's aria-describedby attribute.
Disable this when a label`` tag surrounds the input as well as it's description text, for example in an OptionCard` component.
Whether the generated label id should be included in the input's aria-labelledby attribute.
Disable this when the label tag surrounds the input as well as it's label text,
for example in an OptionCard component.
By default, form elements will throw an error if no label or aria-label is provided. Disable this to suppress the error, for example when building a custom form element, and you want to handle labeling yourself.
Default:md
The size of the option card.
The title to be shown in the card.
Additional classes to be applied to the field node.
Ember-only: this is used internally to detect whether a label
named block is present, and to ignore empty label props if so.
Additional classes to be applied to the input node.
Sets the size attribute on the input element. This controls the visible width of the input in characters.
Whether the component should render with "legacy" styles.
The value associated with this card.
Whether to apply the center-baseline variant.