"box" Macro

Last modified by Lucas Charpentier on 2026/09/18 13:29

Reference

Description

The box macro draws a frame around the wiki content it wraps, above which it can display a title and an image. In the macro list of the editors it appears as "Box", in the "Formatting" category.

The four message macros, "info", "success", "warning" and "error", are built on this one: each is a box carrying its own icon and styling. Reach for one of them when the box carries a message of that kind, and for box when it does not.

Usage

{{box}}
The content to put in the box.
{{/box}}

The content is parsed as wiki content, so it can hold lists, links and other macros. It is not mandatory, but a box with an empty content displays nothing at all rather than an empty frame.

The macro works inline as well as standalone: written inside a paragraph it renders a SPAN, written on its own it renders a DIV.

Every box carries the CSS class box, and a cssClass value is added to it instead of replacing it, so cssClass="mybox" produces class="box mybox". The title is rendered in bold, in its own element carrying the class box-title.

Parameters

NameMandatoryAllowed ValuesDefault ValueDescription
contentnowiki content""The content the box frames. A box whose content is empty displays nothing at all.
cssClassnoa space-separated list of CSS class names""Added to the box class the macro always sets, so this box can be styled on its own.
titlenowiki content""Displayed above the content, in bold.
imagenoan image referencenoneDisplayed above the title. A value without a type prefix is read as the name of an attachment of the current page, or as a URL when it is one.
widthnoa value of the CSS width property""Emitted as the inline style width:<value>. Example: width="300px".

Examples

A Standalone Box With a Title and an Image

Written on its own, the macro renders a DIV: the image first, then the title, then the content. Both the title and the content are wiki content, so they can be formatted.

{{box title="**Powered by XWiki**" image="xwiki-logo.png"}}
This wiki runs on XWiki, an open source platform.
{{/box}}

box-standalone.png

A Standalone Box of a Fixed Width

{{box width="300px" title="Opening hours"}}
Monday to Friday, 9am to 5pm.
{{/box}}

box-width.png

An Inline Box

Written inside a paragraph, the macro renders a SPAN and frames only the words it wraps. An inline box displays neither a title nor an image, whatever the parameters say.

The command is {{box cssClass="command"}}mvn clean install{{/box}} and nothing else.

box-inline.png

Related

Get Connected