模板:Calculator codex radio:修订间差异
wiki>Bawolff 小 7 revisions imported from w:en:Template:Calculator_codex_radio: Importing calculator related template to use with Global gadgets system |
小 导入1个版本 |
||
(没有差异)
| |||
2025年12月16日 (二) 16:40的最新版本
Usage
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
{{Calculator codex radio|id=myradio|name=group1|label=First option|description=Additional text describing the first option}}
produces:
Generally radio buttons form a group. In order for best accessibility, the group of radio buttons all with the same name should be collected into a div with role="radiogroup". If you want to group related radio controls together consisting of multiple radio groups, use role=group for that. 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|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=Third option}}
</div>
You can also have options inline:
<div role="radiogroup" aria-labelledby="mygrouplabel2" id="myradiogroup2">
{{calculator label|codex=1|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>
Template data
Add a radio button for calculator gadget in codex style
| 参数 | 描述 | 类型 | 状态 | |
|---|---|---|---|---|
| codex-div-class | codex-div-class | additional css classes for outer wrapper | 字符串 | 可选 |
| id | id | id value of calculator widget. Can be referenced by other calculator templates | 未知 | 必需 |
| name | name | Name of radio group. All radio buttons in the same group should have the same name | 字符串 | 必需 |
| style | style | CSS to style the radio button widget | 字符串 | 可选 |
| formula | formula | Formula to control if button is on or off. | 未知 | 可选 |
| readonly | readonly | Make button read only. Read only buttons can be adjusted by formula but not by user interaction | 布尔 | 可选 |
| class-live | class-live | extra css classes to add only if gadget is enabled | 未知 | 可选 |
| class | class | extra css class | 字符串 | 可选 |
| default | default | Whether to start in a checked or unchecked state
| 字符串 | 可选 |
| description | description | Additional description to add after the label | 内容 | 可选 |
| label | label | Label for radio button | 未知 | 必需 |
| inline | inline | Make radio buttons be inline (Multiple on one line) instead of being a separate line for each | 布尔 | 可选 |
| custominput | custominput | Add another calculator widget as part of the label for a radio button
| 内容 | 可选 |