<page-measure>

A lightweight measurement and alignment overlay tool. Select elements to see their dimensions, add guides for alignment, and measure distances. Inspired by mesurer.

Press M to activate the measurement tool and try it on this page! On mobile? Tap the floating button in the bottom-right corner.

Try It Out

This page has sample layouts below. Press M to activate, then click elements to measure them.

Navigation

Sidebar content here

Links

More sidebar items

Main Content Area

Feature One

Description of the first feature goes here.

Feature Two

Description of the second feature goes here.

Feature Three

Description of the third feature goes here.

Widget

Aside content

Keyboard Shortcuts

Quick access to all measurement features.

M Toggle measure mode on/off
S Switch to Select mode
G Switch to Guides mode
H Horizontal guide orientation
V Vertical guide orientation
Alt Hold to show distance overlays
Esc Clear current selection
Del Remove last guide
Cmd+Z Undo guide change
Cmd+Shift+Z Redo guide change

Features

Everything you need to measure and align UI elements.

Select Mode

Click any element to see its dimensions (width × height) and position (x, y coordinates). The element is highlighted with a bounding box overlay.

Guides Mode

Click anywhere to place horizontal or vertical guides. Drag guides to reposition them. Use Delete/Backspace to remove the last guide.

Distance Overlays

Hold Alt (or tap the "Off/On" button in the toolbar on mobile) to see distances from the element to viewport edges.

Persistent Guides

Add the persist attribute to save guides in localStorage. They'll be restored when you reload the page.

Mobile & Touch Support

Works on touch devices! Tap the floating button to activate, tap elements to measure, drag guides to reposition.

API Reference

Attributes, methods, and events.

Attributes

AttributeTypeDefaultDescription
highlight-colorString#3b82f6Color for element selection overlays
guide-colorString#f97316Color for alignment guides
persistBooleanfalseSave guides to localStorage
positionStringbottom-rightFAB position: bottom-right, bottom-left, top-right, top-left
hide-fabBooleanfalseHide the floating action button (keyboard-only mode)
disabledBooleanfalseDisable the component

Methods

MethodDescription
toggle()Toggle measurement mode on/off
enable()Enable measurement mode
disable()Disable measurement mode
clearGuides()Remove all guides

Events

EventDescription
measure-enabledFired when measurement mode is activated
measure-disabledFired when measurement mode is deactivated

Usage

Add the component to any page.

<!-- Basic usage --> <script type="module" src="./src/page-measure.js"></script> <page-measure></page-measure> <!-- With custom colors --> <page-measure highlight-color="#8b5cf6" guide-color="#22c55e"> </page-measure> <!-- With persistent guides --> <page-measure persist></page-measure> <!-- Programmatic control --> <script> const measure = document.querySelector('page-measure'); // Enable via JavaScript measure.enable(); // Listen for events measure.addEventListener('measure-enabled', () => { console.log('Measurement mode activated'); }); </script>