模板:MessageBox/doc
{{MessageBox}} is a template for creating message boxes.
It is highly customizable with classes, inline styles, and provided CSS selectors. Optional features such as an image, left border, right-side text (for e.g. shortcuts), and a dismiss function.
It uses the Lua templating language, and more information can be found on the Global Lua Module page. This version is modified to produce a starter style, based on the basic style from the module. To use the full capabilities of this module and remove the default styling, remove the indicated portions of Module:Mbox.
For a traditional wikitext version of this template, see Ambox on Templates Wiki.
Parameters
For examples of how to use these parameters, see #Examples.
Parameter name | Description | Required? | Default |
---|---|---|---|
class
|
Additional classes to the root .mbox element.
|
No | — |
bordercolor
|
The color of the thick left-most border. | No | Stylesheet default |
type
|
Type of mbox as declared as in CSS with variables. Affects color of the thick left-most border. See #Using types. | No | — |
bgcolor
|
The color of the mbox's background. | No | Stylesheet default |
style
|
Additional inline styles to the root .mbox element.
|
No | — |
image
|
An image to be added to the left of all text content. | No | — |
imagewidth
|
The width of the image (height automatically adjusts). | No | 60px
|
imagelink
|
The link to which the image points (could link to the relevant maintenance category, per example). If not included, the image will be un-clickable. | No | — |
header
|
The header (bold text placed at the top). This is typically used to very briefly explain the subject of the mbox itself, as when the mbox is closed, only the header will show. | No | — |
text
|
Non-bold text placed below the header, typically used to explain the subject of the mbox in further or additional detail. When the mbox is closed, this text will be hidden. | No | — |
comment
|
Smaller non-bold text placed below the main text, typically used to add additional links or context about the notice. When the mbox is closed, this text will be hidden. | No | — |
aside
|
Text placed within a small allocation on the right side separated by a light gray border. Most commonly used to show shortcuts to the page in question (such as on policy pages). When the mbox is closed, this text will be hidden. | No | — |
id
|
By default, one close button will close all mboxes on the page. However, to change this, this parameter may be used, given as the name of the mbox implementation (e.g., "Template:Cleanup" would have |id=cleanup ).
|
No | — |
collapsed
|
By default, the mbox will be uncollapsed, and the full contents will be shown. However, to change this, this parameter may be used to set an mbox as collapsed by default (e.g., |collapsed=true would set the mbox to be collapsed by default).
|
No | — |
Design
Some communities may wish to customize the appearance of the mboxes. The most common styling options are provided illustrated in CSS.
- Technical notes
- Additional inline styles to the root
.mbox
element can be achieved via thestyle
parameter in the template.
Examples
Basic MessageBox
{{MessageBox |header = Header text here |text = Normal text here |id = test1 }}
Produces:
Using types
To use types, CSS variables must be added, such as:
If added:
{{MessageBox |header = Header text here |type = important |text = Normal text here |id = test2 }}
Produces:
Depending on your styling, there may not be a visual difference in the above example.
With an image
{{MessageBox |header = Header text here |text = Normal text here |image = Wiki.png |imagelink = |imagewidth = 50px |id = test3 }}
Produces:
With an aside
{{MessageBox |header = Header text here |type = important |text = Normal text here |aside = Aside text here |id = test4 }}
Produces:
Standard/default style
{{MessageBox |header = Header text here |text = Normal text here |comment = Comment text here |image = Wiki.png |aside = Aside text here |id = standard }}
Produces: