Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Label

Way to add a label to a form control from Template:Calculator. Adding labels using this template helps ensure calculators are accessible

Template parameters

ParameterDescriptionTypeStatus
11 label

Text for label

Contentrequired
forfor

The id from the calculator template this label is for

Stringrequired
classclass

CSS class or classes to add to label

Stringoptional
class-liveclass-live

CSS classes applied only when the gadget is enabled

Stringoptional
codexcodex

Make this a codex style label

Booleanoptional
codex-classcodex-class

Extra class on the codex wrapper

Example
cdx-radio__label
Stringoptional
descriptiondescription

[codex mode only] Additional description text about the widget that is not part of the label

Contentoptional
description-iddescription-id

[codex mode only] id for the description element

Stringoptional
flagflag

[Codex mode only] Additional information about the widget. Usually to mark a field as optional

Example
(optional)
Contentoptional
stylestyle

CSS for label

Stringoptional
titletitle

Tooltip to show on hover

Stringoptional

Checkbox

Add a checkbox 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
stylestyle

CSS to style the checkbox 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 checkbox button

Unknownrequired
inlineinline

Make checkbox 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 checkbox button

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

Interface

Add a calculator widget to the page. Like a spreadsheet you can refer to other widgets in the same page.

Template parameters

ParameterDescriptionTypeStatus
idid

The id for this input. This is used to reference it in formula of other calculator templates

Stringrequired
typetype

What type of input box

Suggested values
plain number text radio checkbox passthru hidden range select
Stringrequired
formulaformula

Formula to calculate this field

Example
3*log(a)
Stringsuggested
classclass

CSS classes to add

Stringoptional
class-liveclass-live

CSS class to add only if gadget is active on the page

Stringoptional
decimalsdecimals

Format to a fixed number of decimal digits [Only applies to type=number or type=plain]

Example
2
Numberoptional
defaultdefault

Default value for this field

Stringsuggested
exponential-precisionexponential-precision

Format to this many significant digits, using scientific notation [Only applies to type=number or type=plain]

Example
2
Numberoptional
maxmax

max number allowed (type=number inputs only)

Numberoptional
minmin

min number allowed (type=number inputs only)

Numberoptional
namename

For type=radio what group to assign the radio button to

Unknownoptional
NaN-textNaN-text

Use this text instead of NaN to signify "not a number". Only applies to format=plain or format=text. Plaintext only; wikitext is not supported

Example
Invalid calculation
Stringoptional
placeholderplaceholder

Text to put as a placeholder in empty input

Stringoptional
precisionprecision

Format to this many significant digits, using decimal notation except for really large numbers [Only applies to type=number or type=plain]

Example
2
Numberoptional
readonlyreadonly

Make input box readonly to user input

Booleanoptional
sizesize

Size of input box (How many characters it will fit)

Numberoptional
stepstep

How much to increment a type=number input box

Example
2.5
Numberoptional
stylestyle

CSS to style the input element with

Stringoptional
aria-describedbyaria-describedby

id of an element that is describing this widget (but is not its label). Used by accessibility software.

Stringoptional
aria-labelledbyaria-labelledby

id of attribute that is the label for this element. Normally you should use the {{calculator label}} template instead.

Stringoptional
aria-labelaria-label

label for this calculator widget for accessibility software. Normally you should use {{calculator label}} instead.

Stringoptional
enterkeyhintenterkeyhint

What should enter key be labelled as on the virtual keyboard on mobile phones

Suggested values
enter go done next
Stringoptional
inputmodeinputmode

What type of virtual keyboard to use on mobile phones. Recommended values include text (normal keyboard) decimal (positive number) numeric (number). Other supported values include none (Do not show a keyboard), tel, search, email and url

Suggested values
text numeric decimal
Stringoptional
mappingmapping

A JSON object mapping strings to numbers to alter the display. Only works with type of plain, select or text. The values must be of type number, except for the strings "Infinity" "-Infinity", "default", and "NaN". For select type, can be two layers deep.

Example
{ "one": 1, "two": 2, "Other": "default" }
Stringoptional
rolerole

Aria role. This helps a screen reader understand how to understand the content. For example, role=alert means that it is an urgent alert that should be read out right away. role=marquee means something that changes often and should not be read out by the screen reader. role=log means something where there is new content that gets added to the end which should be told to the user. role=status means it is a status update that should be read out when it changes. Will only be applied if gadget is enabled. If using a role that has an implicit aria-live value (alert, marquee, log, status) you should set aria-live=inherit to prevent the default aria-live from overriding.

Stringoptional
aria-atomicaria-atomic

If content changes, screen readers should read out the entire thing, not just the part that changed

Suggested values
true false
Unknownoptional
aria-relevantaria-relevant

What type of content changes should be read out by screen readers

Unknownoptional
aria-livearia-live

Value for aria-live. This controls if the screen reader should read out changes even when the user is focused elsewhere. Note the default for most calculator widgets is "polite". Set to "inherit" to set no aria-live attribute.

Suggested values
polite inherit off assertive
Unknownoptional
valuevalue

For field types of radio, checkbox and select. Allow setting the default value for a form, including in cases where the field isn't checked by default. Unlike default this won't be shown as a fallback for users without javascript. Note: for radiobuttons and checkboxes the value of the form control will be the result of the formula if set by a formula, but this value if checked by a human.

Stringoptional
checkedchecked

Should the radio button or checkbox start off in checked state. Overrides default. Unlike default this won't affect fallback text for non-js users.

Stringoptional

Toggle

Add a toggle switch button for calculator gadget in codex style

Template parameters

ParameterDescriptionTypeStatus
idid

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

Unknownrequired
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 toggle switch button

Unknownrequired
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

Booleanoptional
labelstylelabelstyle

Additional CSS for the label part

Stringoptional

Text

Add a codex-themed text input box widget to the page for use with the calculator gadget.

Template parameters

ParameterDescriptionTypeStatus
idid

The id for this input. This is used to reference it in formula of other calculator templates

Stringrequired
formulaformula

Formula to calculate this field

Example
3*log(a)
Stringsuggested
readonlyreadonly

Make input box readonly to user input

Booleanoptional
sizesize

Size of input box (How many characters it will fit)

Numberoptional
placeholderplaceholder

The placeholder text provides an example of what type of information is being requested in the input. The placeholder text should further illustrate and support the text input label. However, it should never be the only input description.

Stringoptional
defaultdefault

Default value for this field

Stringsuggested
stylestyle

CSS to style the input element with

Stringoptional
precisionprecision

Format to this many significant digits, using decimal notation except for really large numbers [Only applies to type=number or type=plain]

Example
2
Numberoptional
exponential-precisionexponential-precision

Format to this many significant digits, using scientific notation [Only applies to type=number or type=plain]

Example
2
Numberoptional
decimalsdecimals

Format to a fixed number of decimal digits [Only applies to type=number or type=plain]

Example
2
Numberoptional
NaN-textNaN-text

Use this text instead of NaN to signify "not a number". Only applies to format=plain or format=text. Plaintext only; wikitext is not supported

Example
Invalid calculation
Stringoptional
classclass

CSS classes to add

Stringoptional
class-liveclass-live

CSS class to add only if gadget is active on the page

Stringoptional
errorerror

Mark this field as having invalid input

Booleanoptional
codex-div-classcodex-div-class

Additional css classes to apply to the outer div

Stringoptional

HideIfZero

Allow showing or hiding a page element based on a calculator formula

Template parameters

ParameterDescriptionTypeStatus
formulaformula

Calculator formula to decide whether or not to show

Stringrequired
texttext 1

Wikitext to show or hide

Contentrequired
blockblock

Whether to be a block (div) element or an inline (span) element

Booleanoptional
elementelement

Name of element to use (overrides block). For example, if you want to hide a list item, you would set this to li

Default
span
Example
li
Stringoptional
classclass

Additional css classes

Stringoptional
starthiddenstarthidden

Have the text start off being not shown

Booleanoptional
stylestyle

Additional CSS to add

Stringoptional
class-liveclass-live

Additional css classes to add only once gadget is active

Stringoptional

Codex Radio

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

IfEnabled

Check if the calculator gadget can be used on this page

Template parameters

ParameterDescriptionTypeStatus
enabledenabled 1

Text to show if calculator is supported

Example
Some text {{calculator|type=text}}
Contentrequired
scopedscoped

Mark the calculators inside the enabled branch as isolated from the rest of the page

Booleanoptional
classclass

Extra css classes for the enabled branch

Stringoptional
refreshonloadrefreshonload

Refresh the calculators on the initial page load before any user interaction (required scoped to be set)

Booleanoptional
disableddisabled 2

Text to show if calculator is not enabled (for example during print)

Example
Calculator is not supported
Contentsuggested
class disabledclass disabled

Extra css classes for the disabled branch

Stringoptional