Radio

The Radio widget wraps an <input type="radio"> element.

Radio
//<code-header>
fiddle.title = 'Radio';
//</code-header>
new Container({
    appendTo : targetElement,
    items    : [
        {
            type    : 'radio',
            name    : 'basic-radio',
            text    : 'Yes',
            checked : true
        },
        {
            type : 'radio',
            name : 'basic-radio',
            text : 'No'
        }
    ]
});

Color can be specified, and you can optionally configure text to display in a label to the right of the radio button instead of, or in addition to, a standard field label.

Radio colors
//<code-header>
fiddle.title = 'Radio colors';
//</code-header>
new Container({
    appendTo : targetElement,
    items    : [
        {
            tag   : 'p',
            style : 'font-weight:500',
            html  : 'Do you need jQuery in your web app?'
        },
        {
            type         : 'radio',
            name         : 'radios',
            text         : 'No',
            checked      : true,
            checkedValue : 'A'
        },
        {
            type         : 'radio',
            name         : 'radios',
            text         : 'Probably not',
            checkedValue : 'B'
        },
        {
            type         : 'radio',
            name         : 'radios',
            checked      : true,
            text         : 'Unlikely',
            checkedValue : 'C'
        }
    ]
});

new Container({
    appendTo : targetElement,
    style    : 'margin-top:2em',
    items    : [
        {
            tag   : 'p',
            style : 'font-weight:500',
            html  : 'Are colored radio buttons awesome?'
        },
        // green radio
        {
            type         : 'radio',
            color        : 'b-green',
            checked      : true,
            name         : 'coloredradios',
            text         : 'Sure',
            checkedValue : 'A'
        },

        // blue radio
        {
            type         : 'radio',
            color        : 'b-blue',
            name         : 'coloredradios',
            text         : 'Yes',
            checkedValue : 'B'
        },

        // orange radio
        {
            type         : 'radio',
            color        : 'b-orange',
            name         : 'coloredradios',
            text         : 'Kinda',
            checkedValue : 'C'
        },

        // disabled radio
        {
            type         : 'radio',
            disabled     : true,
            name         : 'coloredradios',
            text         : 'Disabled',
            checkedValue : 'D'
        }
    ]
});

Nested Items

A radio button can also have a container of additional items. These items can be displayed immediately following the field's label (which is the default when there is only one item) or below the radio button. This can be controlled using the inline config.

In the demo below notice how additional fields are displayed for the checked radio button:

Radio items
//<code-header>
fiddle.title = 'Radio items';
//</code-header>
new Container({
    appendTo : targetElement,

    items : {
        singleItem : {
            type         : 'radio',
            text         : 'Single item',
            name         : 'radioItems',
            checkedValue : 'A',
            autoCollapse : true,

            container : [
                {
                    type        : 'textfield',
                    placeholder : 'Additional info...',
                    flex        : 1
                }
            ]
        },

        twoItems : {
            type         : 'radio',
            text         : 'Two items',
            name         : 'radioItems',
            inline       : true,  // can also use false to wrap a single item
            checkedValue : 'B',
            autoCollapse : true,

            container : {
                from : {
                    type        : 'textfield',
                    placeholder : 'From...',
                    flex        : 1
                },
                to : {
                    type        : 'textfield',
                    placeholder : 'To...',
                    flex        : 1,
                    style       : 'margin-inline-start: 1em'
                }
            }
        },

        childForm : {
            type         : 'radio',
            text         : 'Child form',
            name         : 'radioItems',
            checkedValue : 'C',
            autoCollapse : true,

            container : {
                from : {
                    type  : 'textfield',
                    label : 'From',
                    width : 'auto'
                },
                to : {
                    type  : 'textfield',
                    label : 'To',
                    width : 'auto'
                }
            }
        }
    }
});

For a simpler way to create a set of radio buttons, see the RadioGroup widget.

Configs

112

Common

listenersEvents

Other

clearable: Boolean= false

Set this to true so that clicking a checked radio button will clear its checked state.

autoCollapseCheckbox
checkedCheckbox
checkedValueCheckbox
colorCheckbox
columnWidget
nameField
rtlRTL
spanWidget
textCheckbox
valueCheckbox

Accessibility

ariaLabelWidget
keyMapKeyMap

Container

inlineField

CSS

clsWidget
htmlClsWidget
styleWidget
uiWidget

DOM

adoptWidget
appendToWidget
contentWidget
datasetWidget
htmlWidget
idWidget
tagWidget
titleWidget

Float & align

alignWidget
anchorWidget
centeredWidget
draggableWidget
floatingWidget
xWidget
yWidget

Input element

Label

hintField
labelLabelable
labelClsLabelable
labelPositionLabelable
labelsField
labelWidthLabelable

Layout

alignSelfWidget
dockWidget
flexWidget
heightWidget
hiddenWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
textAlignWidget
weightWidget
widthWidget

Misc

badgeBadge
dataFieldWidget
disabledWidget
localeClassLocalizable
localizableLocalizable
maskedWidget
ownerWidget
refWidget
rippleWidget
tabWidget
tooltipWidget

Scrolling

Properties

85

Class hierarchy

isRadio: Boolean= truereadonly
Identifies an object as an instance of Radio class, or subclass thereof.
isRadio: Boolean= truereadonlystatic
Identifies an object as an instance of Radio class, or subclass thereof.
isBadgeBadge
isCheckboxCheckbox
isDelayableDelayable
isEventsEvents
isFieldField
isKeyMapKeyMap
isLabelableLabelable
isLocalizableLocalizable
isValidatableValidatable
isWidgetWidget

Accessibility

keyMapKeyMap

CSS

clsWidget

DOM

appendToWidget
contentWidget
datasetWidget
elementWidget
htmlWidget
idWidget
styleWidget

Float & align

xWidget
yWidget

Layout

alignSelfWidget
flexWidget
heightWidget
marginWidget
maxHeightWidget
maxWidthWidget
minHeightWidget
minWidthWidget
widthWidget

Lifecycle

configBase

Misc

badgeBadge
cellInfoWidget
disabledWidget
errorTipValidatable
labelLabelable
localeHelperLocalizable
localeManagerLocalizable
refWidget
tabWidget
tooltipWidget

Other

$namestaticWidget
checkedCheckbox
columnWidget
inputField
isEmptyField
isValidField
nameCheckbox
rtlRTL
spanWidget
typestaticWidget
valueCheckbox

Visibility

hiddenWidget
isVisibleWidget

Widget hierarchy

ownerWidget
parentWidget

Functions

67

Configuration

applyDefaultsstaticBase

Events

Float & align

alignToWidget
setXYWidget
showByWidget
toFrontWidget

Lifecycle

createstaticWidget
destroystaticBase
initClassstaticWidget

Misc

attachTooltipstaticWidget
fromElementstaticWidget
fromSelectorstaticWidget
getByIdstaticWidget
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

checkCheckbox
clearField
clearErrorValidatable
composeWidget
createOnFrameDelayable
disableWidget
enableWidget
focusWidget
getErrorsValidatable
LstaticLocalizable
maskWidget
onEvents
recomposeWidget
relayAllEvents
selectField
setErrorValidatable
toggleCheckbox
triggerEvents
unEvents
uncheckCheckbox
unmaskWidget

Visibility

hideWidget
showWidget

Widget hierarchy

closestWidget
containsWidget
ownsWidget
queryWidget
queryAllWidget
upWidget

Events

21
actionCheckbox
beforeChangeCheckbox
catchAllEvents
changeCheckbox
clearField
clickCheckbox
destroyEvents
focusInWidget
focusOutWidget
hideWidget
inputField
paintWidget
readOnlyWidget
recomposeWidget
resizeWidget
showWidget
triggerField

Event handlers

21

Typedefs

7

CSS variables

67
NameDescription
--b-radio-check-gapSize of the radio button "checkmark" (the dot)
--b-radio-backgroundRadio button background
Checked
--b-radio-checked-backgroundBackground of the radio button when checked
--b-radio-checked-border-colorRadio button's border-color when checked
--b-radio-checked-colorColor of the radio button "checkmark" (when checked)

Inherited