Jump to content

Template:Calculator codex radio/doc

From Wikipedia, the free encyclopedia

Usage

[edit]

This is to create a codex-style radio {{calculator}} widget. A radio button is used when there is multiple options and the user should only be able to select one.

Please see https://doc.wikimedia.org/codex/latest/components/demos/radio.html#guidelines for best practices.

Example

[edit]
{{Calculator codex radio|id=myradio|name=group1|label=First option|description=Additional text describing the first option}}

produces:

First optionAdditional text describing the first option

Generally radio buttons form a group. In order for best accessibility, the group of radio buttons should be collected into a div with role="radiogroup". The group should have its own label referenced by aria-labelledby. For example:

<div role="radiogroup" aria-labelledby="mygrouplabel" id="myradiogroup">
{{calculator label|codex=1|for=myradiogroup|label=This is a group of options|id=mygrouplabel}}
{{Calculator codex radio|id=myradio1|name=group2|label=First option|description=Additional text describing the first option}}
{{Calculator codex radio|id=myradio2|name=group2|label=Second option|description=Additional text describing the first option}}
{{Calculator codex radio|id=myradio3|name=group2|label=Thid option}}
</div>
This is a group of options
First optionAdditional text describing the first option
Second optionAdditional text describing the first option
Thid option

You can also have options inline:

<div role="radiogroup" aria-labelledby="mygrouplabel2" id="myradiogroup2">
{{calculator label|codex=1|for=myradiogroup2|label=A bunch of inline options|id=mygrouplabel2}}
{{Calculator codex radio|id=myradioin3|name=group3|label=First|inline=1}}
{{Calculator codex radio|id=myradioin2|name=group3|label=Second|inline=1}}
{{Calculator codex radio|id=myradioin1|name=group3|label=Third|inline=1}}
</div>
A bunch of inline options
First
Second
Third

Template data

[edit]

Add a radio button for calculator gadget in codex style

Template parameters

ParameterDescriptionTypeStatus
codex-div-classcodex-div-class

additional css classes for outer wrapper

Stringoptional
idid

id value of calculator widget. Can be referenced by other calculator templates

Unknownrequired
namename

Name of radio group. All radio buttons in the same group should have the same name

Stringrequired
stylestyle

CSS to style the radio button widget

Stringoptional
formulaformula

Formula to control if button is on or off.

Unknownoptional
readonlyreadonly

Make button read only. Read only buttons can be adjusted by formula but not by user interaction

Booleanoptional
class-liveclass-live

extra css classes to add only if gadget is enabled

Unknownoptional
classclass

extra css class

Stringoptional
defaultdefault

Whether to start in a checked or unchecked state

Suggested values
1 0
Stringoptional
descriptiondescription

Additional description to add after the label

Contentoptional
labellabel

Label for radio button

Unknownrequired
inlineinline

Make radio buttons be inline (Multiple on one line) instead of being a separate line for each

Booleanoptional
custominputcustominput

Add another calculator widget as part of the label for a radio button

Example
{{calculator codex text|default=42|id=foo}}
Contentoptional