Radio Button

Definition

<cst-radio>
<sub-theme/>
<sub-font/>
<sub-style/>
<sub-access/>
<sub-item />
<sub-item />
<sub-options />
<sub-help-icon/>
<sub-feature-flag/>
</cst-radio>

OR

<cst-element name="radio" schema="" schema-prop="" value=""/>

Example

<cst-radio id="" value="">
<sub-theme name="" clr-var1="" clr-var2=""/>
<sub-font name="" font-var1="" font-var2=""/>
<sub-style name="" width="" height=""/>
<sub-access can-view="" can-modify=""/>
<sub-item id="" text="" />
<sub-item id="" text="" />
<sub-options items-prop="" item-text-prop="" item-id-prop=""/>
<sub-help-icon name="" position="" title="" link="">
<sub-feature-flag disable-ripple="">
</cst-radio>

Attributes

AttributeValueDescription
idstring typeIdentifier for component.
valuestring typeSpecifies the selected item's id for component.(two way bind attribute)
requiredboolean typeSpecifies if field must be filled.
disabledboolean typeSpecifies if component should be disabled.(aurelia ext attribute)
autofocusboolean typeSpecifies if component should be focused when loaded.
checkedboolean typeSpecifies if radio is checked.
display-typesting type(radio)Specifies the component.
classcst-mat-unchecked
cst-mat-checked
Specifies class to be applied(Multiple classes can be given with space).

sub-theme

object typeSpecifies theme to be used for component.

sub-font

object typeSpecifies fonts to be used for component.

sub-style

object typeSpecifies style to be applied to component.

sub-options

object typeSpecifies the options of component.

sub-help-icon

object typeSpecifies help icon to be displayed.

sub-feature-flag

objectSpecifies what features to enable/disable.
otherany typeAny other info.
schemaobject type Specifies JSON schema.
schema-propstring typeSpecifies property to be used to pick schema.

Sub element attributes

sub-theme

PropertyValueDescription
nameprimary(default)/secondary/customName of the theme.
clr-labelstring typeIf custom then specific/ named color variables

sub-font

PropertyValueDescription
nameroboto (default)/customName of the font
font-textstring typeIf custom then specific/ named font variables.
font-labelstring type
font-errorstring type

sub-style

PropertyValueDescription
namematerial/skeuomorphicName of design to be used.
widthpercentage/pixels/string(x-small,small,medium,large,x-large)Gives width/any other prop value

sub-options

PropertyValueDescription
items-propstring typeProperty of item array
item-id-propstring typeProperty of item's id
item-text-propstring typeProperty of item's display text.

sub-help-icon

PropertyValueDescription
namestring typeIcon name.
positionleft/rightPosition of the icon.
titlestring typeIcon tooltip
linkstring typeLink to be opened on click.

sub-feature-flag

PropertyValueDescription
disable-rippleboolean typeDisables ripple effec when given true.

Schema Examples

Full schema

Fetch appropriate based on schemaProp

let schema = {
type: "object",
required: ["genderId"], //= required
properties: {
regionId: {
type: "number",
title:"Select Gender",//= label for radio
cstAttr: {
raw:{ //loop & add to element
disabled : false,
autofocus : false,
class:'cst-class1',
checked: '',
required: '',
},
subStyle:{ //loop & add to element style
name: '',
width:'',
height:'',
fontSize:''
},
subOptions:{
itemsProp: '',
itemTextProp: '',
itemIdProp: ''
},
subHelpIcon: {
name: '',
position: '',
title:'',
link:''
},
subFeatureFlag: {
disableRipple: ''
},
subTheme:{
name:'',
clrLabel:''
},
subFont:{
name:'',
fontText:'',
fontLabel:'',
fontError:''
}
}
}
}
}
let schemaProp = 'genderId';
let value = 100;
let finalSchema = schemaProp ? schema.properties[schemaProp] : schema;
let data = [
{
id: '',
text: '',
checked: '',
textPosition: ''
}
]

Exact schema

let schema = {
type: "number",
title: "Select Gender", //= label
cstAttr: {
}
}
let schemaProp = '';
let value = 100;
let finalSchema = schemaProp ? schema.properties[schemaProp] : schema;

Nested object

Nested object schemaProp

let schema = {};
let schemaProp = 'EMDDetails.genderId';
let value = 100;
var finalSchema = schema;
let schemaPropSplits = schemaProp.split('.');
for(let prop of schemaPropSplits){
finalSchema = finalSchema.properties[schemaProp];
}

Material Measurement Guidelines

  • min-height = 20px
  • min-width = 20px

SPEC MIN

Events

AttributeDescription
onclickFires when the item clicked.
oninvalidScript to be run when an element is invalid.
onresetFires when reset button is clicked.
onvalidateCustom validate hook, must return error message else considered valid; will be called onchange.

Event Method signature

method(parentRefObj, evtObj, elm, others)

Parameters description

ParameterValueDescription
parentRefObj
parentRefObj = {
parentContext,
loopParentContext,
doubleLoopParentContext
}
Parent Context references
evtObjobjectEvent object
elmobjectElement value
othersanyOther value

OverRidable Classes

  • cst-ovr-radio-elm
  • cst-ovr-radio
  • cst-ovr-radio-label
  • cst-ovr-radio-helper-text
  • cst-ovr-radio-error-text

Unit Test Screenshots

Responsiveness Test Screenshots

Design Images

Demo link

Features

  • Display radio group

  • Text position can be next to radio button

  • Item Selection

  • Every items must have id prop (add in check list)

Points

  • The maximum height of a radio group should be at least one row less than the height of the app’s UI.