Skip to content

parseSides

Converts a string of directional CSS shorthand values into an object with the values expanded.

Expands CSS shorthand the way margin and padding do: one value applies to all sides, two mean vertical then horizontal, three mean top, horizontal, bottom, and four go clockwise from the top. Units are ignored and anything that is not a number becomes 0. Config such as padding and labelPadding accepts this shorthand.

import {parseSides} from "@d3plus/dom";

parseSides("10");
parseSides("10 20");
parseSides("10 20 30");
parseSides("10 20 30 40");
parseSides(15);
parseSides("1em 2px");
parseSides("auto 5");

Parameters

import {parseSides} from "@d3plus/dom";
sidesrequiredstring | number

The CSS shorthand string to expand.