Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


	<h2>A couple of small Typed OM demos</h2>
	<p>▷ Check the devtools console for logs too</p>

	<p class="width-olde">Click to change my width the olde way</p>

	<p class="width-typed">Click to change my width the Typed OM way</p>

	<p class="transform-olde">Transformed the olde way</p>

	<p class="transform-typed">Transformed the Typed OM way</p>


                body {
	/* colours */
	--pink: #B3346C;
	--purple: #832B76;
	--blue: #277E9E;
	--yellow: #E4A834;
	--col1: var(--pink);
	--col2: var(--yellow);
	/* layout */
	min-height: 80vh;
	padding: 2vw 4vw;
	flex-direction: column;
	justify-content: space-evenly;
	align-items: center;

/* button esq styling */
div p {
	display: inline-block;
	width: 300px;
	padding: 1em 1.6em;
	background-color: var(--col1);
	background-image: linear-gradient(30deg, var(--col1) 10%, var(--col2) 100%);
	border: 2px solid white;
	border-radius: 2.4em;
	box-shadow: 1px 1px 4px hsla(0, 0%, 60%, 0.3);
	color: white;
	line-height: 1.4;
	text-align: center;
	text-transform: uppercase;
[class^="transform"] {--col1: var(--blue); --col2: var(--purple);}
[class^="width"]:hover {
	background-image: linear-gradient(30deg, var(--col1) 0%, var(--col2) 100%);
	cursor: pointer;

/* transform styling */
.transform-olde {
	--rotate: 10deg;
	transform: rotate(var(--rotate)) scale(1.2);
.transform-typed {
	transform: rotate(10deg) scale(1.2);




// ==================================== width old style
// get element
const oldeWidthEl = document.querySelector('.width-olde');
// get width -> this forces relayout
const oldeWidth = getComputedStyle(oldeWidthEl).width;
// flag to click back to original size
let wide = false;
// add click & change width
oldeWidthEl.addEventListener('click', function() {
	if (!wide) {
		// finding the value here is hard, so we just set a string with an arbituary unit = '320px';
		wide = true;
	} else { = oldeWidth;
		wide = false;
}, false)

// ======================================= width typed om style
// get element
const typedWidthEl = document.querySelector('.width-typed');
// get width -> does _not_ force relayout \o/
let typedWidth = typedWidthEl.computedStyleMap().get('width');
// add click & change width
typedWidthEl.addEventListener('click', function() {
	// we don't need a flag anymore, number types come with an equals method!
	typedWidth = CSS.px(300).equals(typedWidth) ? CSS.px(320) : CSS.px(300);
	// set value
	this.attributeStyleMap.set('width', typedWidth);
}, false)

// ======================================= transform olde
// get element
const oldeTransformEl = document.querySelector('.transform-olde');
// this returns a matrix and is pretty useless to us
const oldeTransform = getComputedStyle(oldeTransformEl).transform;
// let's update the custom property instead'--rotate', '15deg');

// ================================== transform typed way
// get element
const typedTransformEl = document.querySelector('.transform-typed');
// get transform -> returns array of all transform values as types
let typedTransform = typedTransformEl.computedStyleMap().get('transform');
// create a new transform
const transform = new CSSTransformValue([
  new CSSRotate(CSS.deg(30)),
  new CSSScale(CSS.number(1.2), CSS.number(1.2))
typedTransformEl.attributeStyleMap.set('transform', transform);

console.log('%cOlde width value: ', 'background-color:#E4A834; color: white; padding: 4px; border: 2px solid #B3346C', oldeWidth);
console.log('%cTyped OM width value: ', 'background-color:#B3346C; color: white; padding: 4px; border: 2px solid #E4A834', typedWidth);
console.log('%cOlde transform value: ', 'background-color:#277E9E; color: white; padding: 4px; border: 2px solid #832B76', oldeTransform);
console.log('%cTyped OM transform value: ', 'background-color:#832B76; color: white; padding: 4px; border: 2px solid #277E9E', typedTransform);