This page is protected against editing.

Template:Mbox

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Template documentationview · edit · history · purge ]
This documentation is transcluded from Template:Mbox/doc.

This is used to create message boxes.

Usage

{{Mbox
 |text =
 |type =
 |image =
}}

Template parameters

ParameterDescriptionDefaultStatus
texttextThe text to be displayed.emptyrequired
typetypeChanges the color depending on the message needed. Each has its own preset image, see #Examplesnoticeoptional
imageleft imageOverride the image (“none” for no image). Use format: [[File:Commons-emblem-urgent.svg|class=noviewer|48px]]. The default depends on the type.emptyoptional
imagerightright imageShow an image on the right side, similar to the left one (but empty by default).emptyoptional
textstyletext styleOverride/augment default style of text cell (e.g. alignment — text-align:left; / text-align:right; / text-align:center;).emptyoptional
stylebox styleOverride/augment default style of the whole message box.emptyoptional
classbox classAugment default CSS classes of the whole message box. Particularly useful if your template uses TemplateStyles.emptyoptional
langlanguageSet the language of the text – it's important for right-to-left languages: their image is on the right and imageright is on the left. It helps assistive software (e.g. screen readers) even in left-to-right languages.emptyoptional
widthbox widthSet the width of the box (avoid using it, 80% for example is too large as it leaves only 10% of the page content width for the left/right margins where there may be floating elements generally large of about 250px: if this occurs the Mbox will be displayed at a much lower position on the page, as if there was a "clear:both", so Mbox may not be immediately visible without scrolling down the page with a huge blank space in the middle and all the rest of the page after the Mbox will be also invisible without scrolling). Instead, use the "margin" parameter to set horizontal margins. To avoid the centering, and/or the thick left border, modify e.g. “style=margin-left:0;border-left:2px solid #F4C430”autooptional
marginhorizontal marginSet the horizontal margin of the box (by default it is "auto" if a legacy width is specified, otherwise it is "10%").10%optional
Template data
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData

TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.


Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either ‎useTemplateData=1 or ‎useTemplateData=only on the ‎/doc subpage and transcluding it with {{Documentation}} into the template. ‎<nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.

Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw ‎<templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.

Discussion
There is an ongoing discussion about that matter. Feel invited to comment if you are experienced in either way, your time permits and if you like to share your opinion or to make a suggestion.


Wikipedia's help about TemplateDataCommons-specific information

This is used to create message boxes.

Template parameters[Edit template data]

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
box classclass

Augment default CSS classes of the whole message box. Particularly useful if your template uses TemplateStyles.

Lineoptional
left imageimage

Override the image (“none” for no image). Use format: [[File:Commons-emblem-urgent.svg|class=noviewer|48px]]. The default depends on the type.

Contentoptional
right imageimageright

Show an image on the right side, similar to the left one (but empty by default).

Contentoptional
languagelang

Set the language of the text – it's important for right-to-left languages: their image is on the right and imageright is on the left. It helps assistive software (e.g. screen readers) even in left-to-right languages.

Lineoptional
horizontal marginmargin

Set the horizontal margin of the box (by default it is "auto" if a legacy width is specified, otherwise it is "10%").

Default
10%
Lineoptional
box stylestyle

Override/augment default style of the whole message box.

Lineoptional
texttext

The text to be displayed.

Contentrequired
text styletextstyle

Override/augment default style of text cell (e.g. alignment — text-align:left; / text-align:right; / text-align:center;).

Lineoptional
typetype

Changes the color depending on the message needed. Each has its own preset image, see the template documentation.

Default
notice
Lineoptional
box widthwidth

Set the width of the box (avoid using it, 80% for example is too large as it leaves only 10% of the page content width for the left/right margins where there may be floating elements generally large of about 250px: if this occurs the Mbox will be displayed at a much lower position on the page, as if there was a "clear:both", so Mbox may not be immediately visible without scrolling down the page with a huge blank space in the middle and all the rest of the page after the Mbox will be also invisible without scrolling). Instead, use the "margin" parameter to set horizontal margins. To avoid the centering, and/or the thick left border, modify e.g. “style=margin-left:0;border-left:2px solid #F4C430”

Default
auto
Lineoptional

Additional information

The template is intended to be used in the following namespaces: all namespaces

The template is intended to be used by the following user groups: all users

See also

Localization

This template is not intended to be localized.

Note:

The icon displayed in the message box is clickable and drives to Commons (to see its attributions), but only when the message box is displayed in a "Template:" page (including their talk pages). When the template is displayed in a page belonging to all other namespaces, no link is generated, only the icon is visible directly.

Examples

All possible values for parameter "type"

Examples with more parameters