MMM-AutoScale uniformly scales an entire MagicMirror layout from a fixed
design canvas to the current browser viewport.
It is intended for MagicMirror installations whose modules have already been carefully sized and positioned using fixed measurements. Rather than making each module independently responsive, it preserves the complete composition and scales it as a unit.
- No MagicMirror core modifications
- No
node_helper.js - No external dependencies
- No required
custom.css - Preserves the layout's proportions
- Responds to browser resizing and orientation changes
- Supports
contain,cover, width-based, and height-based scaling - Supports configurable alignment and scale limits
cd ~/MagicMirror/modules
git clone https://github.com/MetroCS/MMM-AutoScale.git
No npm install step is required.
Add the module to the modules array in config/config.js:
{
module: "MMM-AutoScale",
config: {
designWidth: 1920,
designHeight: 1080,
mode: "contain"
}
},Do not assign a position. The module runs without displaying its own DOM content.
Set designWidth and designHeight to the browser viewport dimensions for
which the existing layout was designed. These are CSS-pixel dimensions, not
necessarily the display panel's advertised physical resolution.
Tip
To inspect the current viewport, open the browser console and check:
window.innerWidth
window.innerHeightmode: "contain"Shows the entire design and preserves its aspect ratio. If the viewport has a different aspect ratio, unused space appears on two sides. This is the safest default for digital signage.
mode: "cover"Fills the entire viewport while preserving the aspect ratio. Some content may be cropped.
mode: "width"Scales according to viewport width only. The design may extend beyond the viewport vertically.
mode: "height"Scales according to viewport height only. The design may extend beyond the viewport horizontally.
{
module: "MMM-AutoScale",
config: {
designWidth: 1920,
designHeight: 1080,
mode: "contain",
alignX: "center",
alignY: "center",
allowUpscale: true,
allowDownscale: true,
minScale: 0,
maxScale: Number.POSITIVE_INFINITY,
backgroundColor: "black",
resizeDebounceMs: 100,
debug: false
}
},| Option | Default | Description |
|---|---|---|
designWidth |
1920 |
Width of the original design canvas in CSS pixels |
designHeight |
1080 |
Height of the original design canvas in CSS pixels |
mode |
"contain" |
"contain", "cover", "width", or "height" |
alignX |
"center" |
"left", "center", "right", or a number from 0 to 1 |
alignY |
"center" |
"top", "center", "bottom", or a number from 0 to 1 |
allowUpscale |
true |
Permit enlargement above the original design size |
allowDownscale |
true |
Permit reduction below the original design size |
minScale |
0 |
Smallest permitted scale factor |
maxScale |
Infinity |
Largest permitted scale factor |
backgroundColor |
"black" |
Color visible around a contained layout |
resizeDebounceMs |
100 |
Delay before recalculating after resize |
debug |
false |
Log viewport, scale, and offset calculations |
Numeric alignment values provide intermediate positioning. For example:
alignX: 0.25,
alignY: 0.75{
module: "MMM-AutoScale",
config: {
designWidth: 3840,
designHeight: 2160,
mode: "contain",
backgroundColor: "black"
}
},{
module: "MMM-AutoScale",
config: {
designWidth: 1920,
designHeight: 1080,
mode: "cover",
alignX: "center",
alignY: "center"
}
},- Start MagicMirror in server-only mode.
- Open the instance in a desktop browser.
- Resize the browser window.
- Confirm that the complete layout grows and shrinks uniformly.
Enable logging while testing:
debug: trueThen inspect the browser console.
Uniform scaling cannot simultaneously preserve the design's proportions, show all content, and fill displays having different aspect ratios.
containpreserves everything but may leave unused space.coverfills everything but may crop content.- Stretching independently in each direction is intentionally not supported because it would distort text, images, and spacing.
The module scales document.body, so modules whose behavior is based directly
on window.innerWidth or window.innerHeight still see the physical viewport
rather than the design-canvas dimensions. Most ordinary MagicMirror modules
use DOM layout and scale correctly, but modules that perform their own
viewport-dependent calculations may need separate testing.
Caution
Use only one MMM-AutoScale instance in a MagicMirror configuration.
MMM-AutoScale is a MagicMirror module to scale an entire layout
Copyright © 2026 Dr. Jody Paul
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.