doc
| This is a documentation subpage for Template:Clickable button. It may contain usage information, categories and other content that is not part of the original template page. |
| This template should never be substituted – use {{Clickable button}}. |
| This template uses Lua: |
| Buttons should not be used in the article namespace. If the desire is to "navigate" a reader to a new page, taking them away from the current page, a link is preferred. Buttons are used within Wikipedia to trigger an "action". |
Lua error in Module:Effective_protection_level at line 64: attempt to index field 'TitleBlacklist' (a nil value).
This template styles a link like a button, using the deprecated mediawiki.ui.button module. This expands the clickable area and tap target for the link.
Usage
edit- All parameters
{{Clickable button|wikilink|display|color=color|url=url|class=class|link=}}- wikilink
- Unnamed first parameter; the title of the page being linked. Brackets are not necessary
- display (optional)
- Optional unnamed second parameter; the text to display. Not needed if the text to display is the wikilink itself
|color=or|class=- Color to display.
|color=acceptsblueandred,|class=acceptsmw-ui-progressiveandmw-ui-destructive |url=- URL to link through the button. If no wikilink/display text is provided, will show the URL, otherwise will show the wikilink/display text
|link=no- Use this parameter set to "no" to display a button without linking to anything
Examples
editWikilinks
edit{{Clickable button|Main Page}}→{{Clickable button|Main Page|Click here to visit the main page}}→{{Clickable button|Click here|link=no}}→
Colors
edit{{Clickable button|Main Page}}→ – without defined|color=and|class=, the default is a white button{{Clickable button|Main Page|color=blue}}→{{Clickable button|Main Page|color=red}}→{{Clickable button|Main Page|class=mw-ui-progressive}}→{{Clickable button|Main Page|class=mw-ui-destructive}}→
URLs
edit{{Clickable button|url=https://example.com}}→{{Clickable button|Example|url=https://example.com}}→{{Clickable button|2=Example|url=https://example.com}}→
Adding an icon
editAdding an icon to a button should be avoided. Don't forget to hide the icon from the accessibility DOM by wrapping it in a span that is aria-hidden="true" so that a screen reader doesn't read it out loud.
<span class="mw-ui-button mw-ui-progressive"><span aria-hidden="true">[[File:OOjs UI icon logo-wikimediaCommons-invert.svg|15px|link=|alt=]]</span> More details</span>
Template data
edit<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", "default": "the page being linked to" }, "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", "suggestedvalues": [ "mw-ui-progressive", "mw-ui-destructive" ] }, "style": { "type": "string", "label": "Custom CSS styling", "description": "Allows custom CSS styling to be applied to the button", "example": "border: 2px solid red;", "default": "None" }, "category": { "type": "boolean", "label": "Category switch", "description": "Whether or not categories should be on", "example": "no", "default": "yes", "autovalue": "0" }, "color": { "suggestedvalues": [ "blue", "red" ], "description": "Defines the visual type of the button", "type": "string" } }, "description": "Styles a link like a button, using the mediawiki.ui.button module", "format": "inline" } </templatedata>
See also
edit- commons:Template:Clickable button, corresponding clickable button at Commons.
- phab:T146923, which dropped support for
mw-ui-constructive, the CSS class for green buttons