跳转到内容

模板:Calculator codex toggle

来自天灾之下:危险连接资料站
Hyucen​(留言 | 贡献)2025年12月16日 (二) 16:40的版本 (导入1个版本)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
模板文档

Usage

This is to create a codex-style toggle switch {{Calculator }} widget.

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

Example

{{Calculator codex toggle|id=mycheck|label=My toggle|description=Additional text describing the toggle}}

produces:

My toggleAdditional text describing the toggle

If you have multiple toggle switches that should be grouped together, you should put them all in a <div> with role="group". This helps with accessibility. The group should have its own label referenced by aria-labelledby. For example:

<div role="group" aria-labelledby="mygrouplabel" id="mytogglegroup">
{{calculator label|codex=1|for=mytogglegroup|label=This is a group of toggles|id=mygrouplabel}}
{{Calculator codex toggle|id=mycheck1|label=First option|description=Additional text describing the first option}}<br>
{{Calculator codex toggle|id=mycheck2|label=Second option|description=Additional text describing the first option}}<br>
{{Calculator codex toggle|id=mycheck3|label=Third option}}
</div>
This is a group of toggles
First optionAdditional text describing the first option

Second optionAdditional text describing the first option

Thid option

Template data

Add a toggle switch button for calculator gadget in codex style

模板参数[编辑模板数据]

参数描述类型状态
idid

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

未知必需
formulaformula

Formula to control if button is on or off.

未知可选
readonlyreadonly

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

布尔可选
class-liveclass-live

extra css classes to add only if gadget is enabled

未知可选
classclass

extra css class

字符串可选
defaultdefault

Whether to start in a checked or unchecked state

推荐值
1 0
字符串可选
descriptiondescription

Additional description to add after the label

内容可选
labellabel

Label for toggle switch button

未知必需
hiddendescriptionhiddendescription

Hide description label. If set, the label will be used for screen readers but not shown to users. The label field is still mandatory

布尔可选
labelstylelabelstyle

Additional CSS for the label part

字符串可选