Template:Clickable button 2/doc: Difference between revisions

From escforumwiki
Jump to navigation Jump to search
en>Smtchahal
Note about javascript
Santos (talk | contribs)
m 42 revisions imported
 
(31 intermediate revisions by 24 users not shown)
Line 1: Line 1:
{{template shortcut|CLB2}}
{{Documentation subpage}}
This template generates a clickable button that is styled using the mediawiki.ui.button module. It can be used in the following ways,
{{template shortcut|CLB2|Click}}
{{lua|Module:Clickable button 2}}


*'''Code: '''<code><nowiki>{{Clickable button 2/sandbox|Main Page}}</nowiki></code>
This template styles a link like a button, using the mediawiki.ui.button module. This expands the clickable area and tap target for the link. It can be used in the following ways,
**'''Result: '''{{Clickable button 2/sandbox|Main Page}}
 
*'''Code: '''<code><nowiki>{{Clickable button 2/sandbox|Main Page|Cover page}}</nowiki></code>
*'''Code: '''<code><nowiki>{{Clickable button 2|Main Page}}</nowiki></code>
**'''Result: '''{{Clickable button 2/sandbox|Main Page|Cover page}}
**'''Result: '''{{Clickable button 2|Main Page}}
*'''Code: '''<code><nowiki>{{Clickable button 2/sandbox|Home|url=http://en.wikipedia.org}}</nowiki></code>
*'''Code: '''<code><nowiki>{{Clickable button 2|Main Page|Cover page}}</nowiki></code>
**'''Result: '''{{Clickable button 2/sandbox|Main Page|url=http://en.wikipedia.org}}
**'''Result: '''{{Clickable button 2|Main Page|Cover page}}
*'''Code: '''<code><nowiki>{{Clickable button 2/sandbox|Main Page|class=mw-ui-constructive}}</nowiki></code>
*'''Code: '''<code><nowiki>{{Clickable button 2|Main Page|url=http://en.wikipedia.org}}</nowiki></code>
**'''Result: '''{{Clickable button 2/sandbox|Main Page|class=mw-ui-constructive}}
**'''Result: '''{{Clickable button 2|Main Page|url=http://en.wikipedia.org}}
*'''Code: '''<code><nowiki>{{Clickable button 2/sandbox|Main Page|class=mw-ui-destructive}}</nowiki></code>
*'''Code: '''<code><nowiki>{{Clickable button 2|Main Page|class=mw-ui-destructive}}</nowiki></code>
**'''Result: '''{{Clickable button 2/sandbox|Main Page|class=mw-ui-destructive}}
**'''Result: '''{{Clickable button 2|Main Page|class=mw-ui-destructive}}
*'''Code: '''<code><nowiki>{{Clickable button 2/sandbox|Main Page|class=mw-ui-progressive}}</nowiki></code>
*'''Code: '''<code><nowiki>{{Clickable button 2|Main Page|class=mw-ui-progressive}}</nowiki></code>
**'''Result: '''{{Clickable button 2/sandbox|Main Page|class=mw-ui-progressive}}
**'''Result: '''{{Clickable button 2|Main Page|class=mw-ui-progressive}}
 
'''Note: '''After the changes outlined in Phabricator task {{Phab|T110555}} were implemented, <code><nowiki>{{Clickable button 2|Main Page|class=mw-ui-constructive}}</nowiki></code> produces the same output as <code><nowiki>{{Clickable button 2|Main Page|class=mw-ui-progressive}}</nowiki></code>.
 
=== Template data ===
<templatedata>
{
"params": {
"1": {
"required": true,
"label": "Link/Label",
"description": "Defines the page to link to, and uses that page's title as the text for the button",
"example": "Foobar",
"type": "wiki-page-name"
},
"2": {
"suggested": true,
"label": "Label",
"description": "Defines the text that appears on the button"
},
"url": {
"type": "url",
"label": "URL",
"description": "Defines a web address for the button to link to",
"example": "https://www.example.com"
},
"class": {
"type": "string",
"description": "Defines the visual type of the button",
"example": "mw-ui-progressive, mw-ui-destructive"
},
"style": {
"type": "string"
},
"category": {
"type": "boolean"
}
},
"description": "Styles a link like a button, using the mediawiki.ui.button module",
"format": "inline"
}
</templatedata>


Note that if a browser does not have JavaScript enabled then no button is displayed but the text will still be displayed.
=== See also ===
=== See also ===
* [[commons:Template:Clickable button]], corresponding clickable button at Commons.
* [[commons:Template:Clickable button]], corresponding clickable button at Commons.
* [https://design.wikimedia.org/style-guide/components/buttons.html Wikimedia design style guide advice on buttons]


{{Button templates}}
{{Button templates}}
<includeonly>
<includeonly>{{Sandbox other||
<!-- Categories and interwikis go here: -->
<!-- Categories and interwikis go here: -->
[[Category:Wikipedia formatting and function templates]]
[[Category:Wikipedia formatting and function templates]]
[[Category:Wikipedia button templates]]
[[Category:Wikipedia button templates]]


</includeonly>
}}</includeonly>

Latest revision as of 19:32, 8 June 2022

This template styles a link like a button, using the mediawiki.ui.button module. This expands the clickable area and tap target for the link. It can be used in the following ways,

  • Code: {{Clickable button 2|Main Page}}
  • Code: {{Clickable button 2|Main Page|Cover page}}
  • Code: {{Clickable button 2|Main Page|url=http://en.wikipedia.org}}
  • Code: {{Clickable button 2|Main Page|class=mw-ui-destructive}}
  • Code: {{Clickable button 2|Main Page|class=mw-ui-progressive}}

Note: After the changes outlined in Phabricator task T110555 were implemented, {{Clickable button 2|Main Page|class=mw-ui-constructive}} produces the same output as {{Clickable button 2|Main Page|class=mw-ui-progressive}}.

Template data

Styles a link like a button, using the mediawiki.ui.button module

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
Link/Label1

Defines the page to link to, and uses that page's title as the text for the button

Example
Foobar
Page namerequired
Label2

Defines the text that appears on the button

Unknownsuggested
URLurl

Defines a web address for the button to link to

Example
https://www.example.com
URLoptional
classclass

Defines the visual type of the button

Example
mw-ui-progressive, mw-ui-destructive
Stringoptional
stylestyle

no description

Stringoptional
categorycategory

no description

Booleanoptional

See also