FANDOM


Mbox is a module for creating message boxes.

Features

  • 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.

How to install

Module

First thing is the module itself. You don't need to copy the code. Just create a module titled Module:Mbox (or any other—just remember to adjust #invoke calls) and put this in the code

return require('Dev:Mbox')


CSS

Next, add the following to your Common.css or Wikia.css.

There are two types of CSS rules for Mbox. The first type is the structural/functionality CSS which should not be changed, lest it break the Mbox. The second type is the design of the Mbox, which should be modified to fit your community's needs. For the design-related selectors you should use, see #Design.

The following CSS represents the base, and can be found at MediaWiki:Global Lua Modules/Mbox.css.

.mbox {
    --type-important: rgba(200, 0, 0, 0.8);
    --type-moderate: rgba(233, 124, 47, 0.8);
    --type-minor: rgba(241, 197, 37, 0.8);
    display: flex;
    position: relative;
    background-color: rgba(255, 255, 255, 0.7);
    border: 1px solid #d6d6d6;
    border-left-width: 8px;
    border-left-color: #d6d6d6;
    border-radius: 3px;
    margin-bottom: 5px;
    min-height: 32px;
}
 
.mbox.mbox-type-important {
    border-left-color: var(--type-important);
}
 
.mbox.mbox-type-moderate {
    border-left-color: var(--type-moderate);
}
 
.mbox.mbox-type-minor {
    border-left-color: var(--type-minor);
}
 
.mbox__content {
    display: table;
    box-sizing: border-box;
    width: 100%;
    padding: 8px 15px;
}
 
.mbox__content__image {
    display: table-cell;
    width: 40px;
    height: 100%;
    text-align: center;
    vertical-align: middle;
    padding-right: 15px;
}
 
.mbox__content__wrapper {
    display: table-cell;
    vertical-align: middle;
}
 
.mbox__content__header {
    display: block;
    font-weight: bold;
}
 
.mbox__content__text {
    display: block;
}
 
.mbox__content__text__comment {
    font-size: small;
}
 
.mbox__content__aside {
    display: table-cell;
    width: 100px;
    vertical-align: middle;
    text-align: center;
    padding-left: 15px;
    border-left: 1px solid #d6d6d6;
}
 
.mbox__close {
    position: absolute;
    right: 0;
    top: 0;
    padding: 2px 7px;
    font-weight: bold;
    font-size: 16px;
    color: #bbb;
    cursor: pointer;
    transition: all .15s ease-in;
}
 
.mbox__close:hover {
    color: #777;
}
 
.mbox__close:after {
    content: '×';
}
 
.mw-collapsed + .mbox__close {
    transform: rotate(45deg);
    padding: 4px 7px 5px 2px;
}

Template

The module is designed to be used as a regular template. To do that just create a template (ex: Template:Mbox) with following content:

{{#invoke:Mbox|main}}

Now the template you created will accept parameters documented below.

These parameters can also be passed directly to the #invoke and will act as defaults. Their values will be overridden by same ones passed to the template.

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. 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 below:

.mbox {
    /* the background of the entire box */;
    background-color: ;
 
    /* the border color of the entire box */
    border-color: ;
 
    /* the border thickness of the entire box */
    border-width: ;
 
    /* the default thick left border color; note this can be changed from within the template implementations using the "color" parameter */
    border-left-color: ;
 
    /* the rounded-ness of the corners */;
    border-radius: ;
 
    /* the baseline font-size of the mbox */
    font-size: ;
}
 
.mbox__content {
    /* the padding inside the mbox */
    padding: ;
}
 
.mbox__content__image {
    /* the minimum width of the mbox's image (if bigger, use the "imagewidth" parameter in the template) */
    width: ;
 
    /* the spacing to the left of the text (i.e., the right of the image) */
    padding-right: ;
}
 
.mbox__content__text__comment {
    /* the size of the text in the "comment" parameter */
    font-size: ;
}
 
.mbox__content__aside {
    /* any particular modifications to the "aside" area can go here */
 
    /* the maximum width of the aside area */
    width: ;
}
 
.mbox__close {
    /* the appearance of the close symbol here */
}
 
.mbox__close:after {
    /* overwrite "content" here if you do not wish for the close symbol to be × */
    content: '';
}
 
.mw-collapsed + .mbox__close {
   /* modifications to the close symbol when the box is closed */
}
 
.mw-collapsed + .mbox__close:after {
   /* overwrite "content" here if you do not wish for the close symbol to be + when the box is closed */
   content: '';
}
Technical notes
  • The mbox module uses the BEM selector convention for readability and to make future additions to the HTML structure easier.
  • Additional inline styles to the root .mbox element can be achieved via the style parameter in the template.

Examples

Different parameters

Basic mbox

{{mbox
|header      = Header text here
|text        = Normal text here
|bordercolor = red
|id          = test1
}}

Produces:

Header text here
Normal text here

Using types

To use types, CSS variables and helper classes must be added, such as:

:root {
    --type-important: rgba(200, 0, 0, 0.8);
    --type-moderate: rgba(233, 124, 47, 0.8);
    --type-minor: rgba(241, 197, 37, 0.8);
}
 
/* NB: The following helper classes are required after <https://github.com/Wikia/app/commit/db84dac8d9bcaaf5d0bee993b11dc77c6792dc79>. */
 
.mbox.mbox-type-important {
    border-left-color: var(--type-important);
}
 
.mbox.mbox-type-moderate {
    border-left-color: var(--type-moderate);
}
 
.mbox.mbox-type-minor {
    border-left-color: var(--type-minor);
}

If added:

{{mbox
|header = Header text here
|type   = important
|text   = Normal text here
|id     = test2
}}

Produces:

Header text here
Normal text here

Image

{{mbox
|header     = Header text here
|text       = Normal text here
|image      = Wiki.png
|imagelink  = Global Lua Modules
|imagewidth = 50px
|id         = test3
}}

Produces:

Wiki
Header text here
Normal text here

Aside

{{mbox
|header = Header text here
|type   = important
|text   = Normal text here
|aside  = Aside text here
|id     = test4
}}

Produces:

Header text here
Normal text here
Aside text here

Bit of everything

{{mbox
|header    = Header text here
|text      = Normal text here
|comment   = Comment text here
|image     = Wiki.png
|aside     = Aside text here
|id        = test5
|collapsed = true
}}

Produces:

Wiki
Header text here
Normal text here
Comment text here
Aside text here

Restyled mboxes

Standard/default style

{{mbox
|header  = Header text here
|text    = Normal text here
|comment = Comment text here
|image   = Wiki.png
|aside   = Aside text here
|id      = standard
}}

Produces:

Wiki
Header text here
Normal text here
Comment text here
Aside text here

Wookieepedia style

Reproducing w:c:starwars:Template:Citation.

Leia holo
Help me <username>, you're my only hope
This article or section is in need of referencing per Wookieepedia's sourcing guidelines.
This article needs appropriate citations. Help us improve this article by referencing valid resource material. Remove this notice when finished.
CSS
.mbox {
    background-color: #7bb0d8;
    border: none;
    border-radius: 10px;
}
 
.mbox__close {
    color: #0c8787;
    font-weight: normal;
    font-size: 13px;
}
 
.mbox__close:after {
    content: '[hide]';
}
 
.mw-collapsed + .mbox__close {
    transform: none;
    padding: 2px 7px;
}
 
.mw-collapsed + .mbox__close:after {
    content: '[show]';
}

Final Fantasy Wiki style

Reproducing w:c:finalfantasy:Template:Rename.

Auron Avatar
Auron: Once Rename fixes its title, we leave.
This page is named incorrectly according to policy. Administrators should retitle it and pages that link to it should be relinked to the new title.
CSS
.mbox {
    border-top: 3px solid #1e9de3;
    color: #fff;
    background: linear-gradient(180deg,rgba(5,37,78,.5) 0,rgba(5,37,78,.5) 75%,rgba(5,37,78,0));
}

Technical and miscellaneous

  • There is no category parameter. In order to inject a category onto an article using a certain mbox implementation, simply add <includeonly>[[Category:{{{category}}}]]</includeonly>. If you wish to make the injection of the category optional, add <includeonly>{{#ifeq: {{{1|}}} | nocat | | [[Category:{{{category}}}]] }}</includeonly>.

See also

Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+