Skip to main content

Radio

Generates a radio input field. There are various different options available to control the position of the radio and labels.

note

It is expected you will need more than one radio input to allow people to choose between a selection of options, you may want to look at the choice helper which lets you supply a group of options to be rendered as radio inputs.

Basic usage

{{
form.radio({
'label': 'My label',
'id': 'guid-' ~ random(),
'name': 'radio-1'
})
}}

Helper options

You can configure this helper using the common helper options, the following options are specific to this helper.

OptionTypeDescription
input_placementstringleft (default) / right position of the input vs the label value

Positioning

Inline

The form.radio_inline() helper creates a <label> element with the radio placed inside, this allows the radio to be positioned either before or after the label value through the input_placement option.

{{
form.radio_inline({
'label': 'Standard left aligned',
'id': 'guid-' ~ random(),
'name': 'radio-3'
})
}}

{{
form.radio_inline({
'label': 'Right aligned',
'id': 'guid-' ~ random(),
'name': 'radio-4',
'input_placement': 'right'
})
}}

Indented

Using form.radio_inline will cause the radio input to not follow the normal flow of a regular Pulsar form. If you want to maintain form alignment, use the .form__group--indent class to restore the position.

{{
form.radio_inline({
'label': 'Standard inline position',
'id': 'guid-' ~ random(),
'name': 'radio-5'
})
}}
{{
form.radio_inline({
'label': 'Indented position',
'class': 'form__group--indent',
'id': 'guid-' ~ random(),
'name': 'radio-6'
})
}}