Options
All
  • Public
  • Public/Protected
  • All
Menu

Radio button powered by Angular Material library.

Example of usage

export const component: DraymanComponent = async ({ forceUpdate }) => {
    let favSeason;
    let favAnimal;

    const onSeasonChange = async ({ value }) => {
        favSeason = value;
        await forceUpdate();
    }

    const onAnimalChange = async ({ value }) => {
        favAnimal = value;
        await forceUpdate();
    }

    return () => {
        const seasonRadioGroup = {
            options: [{
                label: 'Winter',
                value: 'winter'
            }, {
                label: 'Spring',
                value: 'spring'
            }, {
                label: 'Summer',
                value: 'summer'
            }, {
                label: 'Autumn',
                value: 'autumn'
            }],
            label: 'Pick your favorite season',
            onValueChange: onSeasonChange,
            value: favSeason,
        }

        const animalRadioGroup = {
            options: [{
                label: 'Dog',
                value: 'dog'
            }, {
                label: 'Cat',
                value: 'cat'
            }],
            label: 'Pick your favorite animal',
            onValueChange: onAnimalChange,
            value: favAnimal,
        }

        return (
            <div>
                <drayman-radio-group {...seasonRadioGroup} />
                <drayman-radio-group {...animalRadioGroup} direction="row" />
                <div>{favSeason && `Your favorite season is ${favSeason}.`}</div>
                <div>{favAnimal && `Your favorite animal is ${favAnimal}.`}</div>
            </div>
        );
    };
}

Hierarchy

Index

Properties

Optional direction

direction: "column" | "row"

Direction of option list. column by default.

Optional disabled

disabled: boolean

Whether the control is disabled.

Optional error

error: string

Error text to be shown underneath the form field control.

Optional helpText

helpText: string

Hint text to be shown underneath the form field control.

Optional label

label: string

The floating label for a field.

Optional onValueChange

onValueChange: ElementEvent<{ value: string }>

Executed with an input value from user.

Optional options

options: { label: string; value: any }[]

Array of radio button options.

Optional ref

ref: string

Optional style

style: CSS

Optional updateOnBlur

updateOnBlur: boolean

Wether value of the field should be emitted when user is blurred out of the control.

Optional value

value: string

Value of the input.