Template:Messagebox
Parameters
The first unnamed parameter will determine the icon displayed and give the table a class.
You can replace the default icon with something else using the image parameter, e.g.:
{{messagebox|warning|image = File.svg| {{lorem ipsum}} }}
produces:
Alternatively, the first parameter can be arbitrary wikicode, e.g. a math tag, or an image of any size:
{{messagebox |class=mb-centered m1 |1=<math>3x-5y=6</math> <math>2x+4y=2</math> <math>x=?</math> <math>y=?</math> |2=This article/section deals with mathematical concepts appropriate for a student in mid to late high school. }}
produces:
{{messagebox |class=mb-centered |[[File:Human.gif|200px]] |This user is an idiot. }}
produces:
It can also be omitted entirely, in which case no icon will be displayed.
See the Icons category for more icons.
The second unnamed parameter will be the contents of the messagebox.
The class parameter can be used to add one or more css classes to the box. For example, mb-fullwidth will make the box 100% wide instead of 80%.
Multiple classes should be separated by whitespace.
class | resulting style |
---|---|
mb-fullwidth | |
mb-centered | |
mb-autowidth | |
mb-nomargin mb-autowidth | |
mb-brainwatermark-light | |
mb-brainwatermark-dark |
Nesting
You can use a messagebox within the text part of a messagebox. The nested messagebox will automatically be shrinked, its borders will be removed and a separator line will be added above.
Styling
The class parameter can be used to add a class specific to one template, to change the style of that one template. For example, Template:Mothball uses the class mothball to change the background color.
To avoid name clashes use the mb prefix for messagebox class names.
To style the messagebox using a class, use the css selector .messagebox.classname. For example, the background of Template:Mothball is changed by the following code [1]:
.messagebox.mothball {
background-color: #FFC;
}
To style the table cells (both the image and the text):
table.messagebox.classname td {
background-color: red;
}
The table cells also have classes that allow you to style them separately, these are mb-image and mb-text. The following example changes the background color of the image to green and the font color of the text to blue:
table.messagebox.classname td.mb-image {
background-color:green;
}
table.messagebox.classname td.mb-text {
color:blue;
}
Note that since the purpose of this template is to give message boxes a consistent look, per-template styling should be kept to a minimum.