About
This page explains how to create overlay themes, which are a new feature in Webmin 1.450 and later. These allow you to easily modify the colors, icons and CSS of another theme, without having to create or duplicate its entire layout.
Introduction to overlay themes
Implementing a Webmin theme from scratch is a lot of work, as it involves creating icons, CSS, index CGI scripts and much more. Most theme developers only really want to change the appearance of one of the more common themes, like Framed Theme (in the gray-theme directory). Overlays provide an easy way to do this - in effect, they are meta-themes that are layered on top of an existing theme.
Once an overlay theme is installed, it can be selected globally in the Webmin Configuration module on the Webmin Themes page, or in the Change Language and Theme module. Each overlay theme is typically designed to modify the appearance of one or more core themes, specified in its theme.info file.
Overlay theme files
Like regular themes, an overlay theme is simply a directory under the Webmin root. This is normally /usr/libexec/webmin or /usr/share/webmin , and can be found in the root line of the /etc/webmin/miniserv.conf file. If you want to create your own overlay, just create a sub-directory under the root, named something like my-overlay-theme .
This directory must contain a theme.info file, which uses the same text line by line name=value format seen in other Webmin configuration files. The only required names are:
descA description for this theme, such as My Overlay Theme
overlayThis must be set to 1 to indicate that this is an overlay theme.
overlaysThe value must be a space-separated list of real theme directories that this can be used with.
An example theme.info file might look like:
desc=My Overlay Theme
overlay=1
overlays=gray-theme
version=1.0
A theme can also contain a config file, also in the same
format. It’s entries are used to apply the actual changes in Webmin’s appearance that the theme makes. Some of the entries you may want to set are:
headhtmlHTML that will be included inside the
<head>section of each Webmin page.inbodyText that will be included inside the
<body>tag itself.prebodyHTML that will be included at the top of the
<body>section of each page.postbodyHTML that will be included at the bottom of the
<body>section on each page. The same substitutions asprebodyare done.prebodyincludeFile that will be read and included at the top of the
<body>section of each page.postbodyincludeFile that will be read and included at the bottom of the
<body>section on each page.
Because most of the UI changes an overlay theme might want to make can be done using CSS, you could create a config file containing just:
headhtml=<link rel='stylesheet' type='text/css' href='/unauthenticated/overlay.css'>
And then create the file unauthenticated/overlay.css under the theme’s directory. This can be used to modify CSS styling defined in the original theme, such as in the file gray-theme/unauthenticated/style.css . For example, you could make the page background pink with an overlay.css file like:
body { background-color: #ffeeee; }
html { background-color: #ffeeee; }
CSS styling
All Webmin UI elements have CSS classes, which can then be styled by a overlay theme’s .css file. Some of the useful classes are:
ui_tableThe table that contains inputs, started by
ui_table_startfunctionui_table_bodyThe inner table of inputs, also created by
ui_table_startfunctionui_table_rowThe table row containing an input, generated by
ui_table_rowfunctionui_labelThe label next to an input, generated by
ui_table_rowfunctionui_valueThe table element containing the input, generated by
ui_table_rowfunctionui_table_spanAn input table row that spans its whole width
ui_columnsA multi-column table, generated by
ui_columns_startfunctionui_columns_headsThe headings row of a multi-column table
ui_columns_rowA single row in a multi-column table
ui_checked_columnsA row in a multi-column table with a checkbox in the first column
ui_radio_columnsA row in a multi-column table with a radio button in the first column
ui_columns_headerAn additional headings row in a multi-column table
ui_emptymsgThe text displayed if a multi-column table is empty
ui_formStart of a form generated by
ui_form_startfunctionui_form_end_buttonsThe table containing buttons at the end of a form=
ui_textboxA text input box, single line
ui_uploadA file upload input box.
ui_passwordA password text box
ui_selectA single or multi-element select input
ui_multi_selectThe table surrounding a multi-element left-right select input
ui_radioA single radio button
ui_checkboxA single checkbox input
ui_textareaA multi-line text box
ui_opt_textboxThe text box for an optional input field, as generated by
ui_opt_textboxfunctionui_submitA single submit button
ui_dataThe span around year / month / day inputs
ui_buttons_tableThe table around a set of action buttons, started by the
ui_buttons_tablefunctionui_buttons_formThe form for a single button in a buttons table
ui_buttons_rowThe
<tr>for a row in a buttons tableui_buttons_labelThe
<td>containing the button in a buttons table rowui_buttons_valueThe
<td>containing the description text in a buttons table rowui_buttons_hrThe
<tr>for a row in a buttons table that just contains a separatorui_post_headerThe
<center>block for a post-page-title messageui_footerThe
<p>block generated byui_footerfunctionui_subheadingThe
<h3>block containing text generated by theui_subheadingfunctionui_tabsThe table surrounding tabs and their contents, generated by
ui_tabs_startfunctionui_tabThe
<td>for a single tab titleui_tabs_boxThe table surrounding all tab contents
ui_tabs_startThe
<div>that surrounds the contents of a single tabui_grid_tableThe table containing all HTML generated by the
ui_grid_tablefunctionui_grid_rowThe
<tr>for a single row in a grid tableui_grid_cellThe
<td>for a single cell in a grid tableui_radio_tableThe table surrounding all options generated by the
ui_radio_tablefunctionui_confirmationThe
<center>surrounding a confirmation form
Overlaying files
An overlay theme can replace icons, CSS or other files in the base theme by simply including them in its directory using the same paths. For example, you could replace the Webmin logo that appears on the main page by creating the file images/webmin-blue.png under your theme’s directory.
Replacing CSS files is not recommended though, as this will break most existing UI elements. Instead, add to the base theme’s CSS by using the headhtml option described above.
Example overlay theme
To see a very simple overlay theme in action, install the example as follows:
- Login to Webmin and go to Webmin ⇾ Webmin Configuration ⇾ Webmin Themes
- Click on Install theme, and enter the URL
http://download.webmin.com/download/modules/overlay-theme.wbt.gz - After installation, go back to the Webmin Themes page and on the Change overlay tab select the newly installed CSS Overlay Demo Theme
- Click the Change button to activate it
You should now see that your Webmin pages have a pink background. To look at the source for this theme, SSH into your system and cd to the overlay-theme directory under the Webmin root. This will probably located in /usr/libexec/webmin/overlay-theme, or /usr/share/webmin/overlay-theme directory.