Skip to main content

Radio: React

An accordion component is a list of items, allowing each item’s content to be expanded and collapsed by clicking its header.

Installation

Before you can start using the @mediahuis/chameleon-react component, you’ll need to install it, for more information check: Getting started for developers.

With that done, you’re now ready to implement the component in your application.

import { Radio } from '@mediahuis/chameleon-react';

export default function Example() {
return <Radio label="Example" />;
}

Properties

PropertyTypeDefaultRequiredDescription
actionReactNode-NoContents displayed within the ActionLabel.
checkedBoolean-NoSpecifies whether the radio button is checked.
classNameString-NoAllows extending the class names of the Radio component.
disabledBoolean-NoSpecifies whether the radio button is disabled.
errorBoolean-NoSpecifies whether the radio button is displayed with an error state. This adds necessary accessibility tags.
idString-YesThe unique HTML id attribute for the radio button. It is also used for associating the label and message components for accessibility.
labelReactNode-NoContents displayed within the PrimaryLabel, which serves as the main label for the radio button.
labelIdString`${id}-label`NoThe unique HTML id attribute. It is used for associating the label and the radio components for accessibility.
labelHiddenBoolean-NoSpecifies whether the label for the radio button is visually hidden, while still being required for accessibility.
labelPlacement'left' | 'right'-NoDetermines the placement of the label relative to the radio button.
labelPropsGenericComponentPropsWithoutAs-NoAdditional props to be passed to the label component.
messageReactNode-NoContents displayed beneath the label, providing additional information or instructions.
onChangeChangeEventHandler-NoEvent handler function called when the radio button's checked state changes.
optionalLabelString-NoContents displayed within the OptionalLabel, which represents optional information or instructions related to the radio button.
requiredBoolean-NoSpecifies whether the radio button is required.
valueString-NoThe value associated with the radio button.
inputPropsReact.HTMLProps-NoObject containing additional props passed to the input component.

required

Chameleon form inputs are required by default, with the required attribute automatically set. To mark a field as optional, pass the optionalLabel prop to remove the required attribute.