0px
layout shift. Borders keep their width; only their colour turns transparent.
A PostCSS plugin
postcss-sketchify is a PostCSS plugin that turns the borders, fills and underlines of plain CSS into hand-drawn SVG sketches at build time. Every element keeps its position and size, down to the pixel.
npm i -D postcss-sketchify
0px
layout shift. Borders keep their width; only their colour turns transparent.
0 Lines
of JavaScript at runtime. The drawings are SVG, written into your CSS.
+2–11 KB
gzip for a typical page. A budget warning tells you when it grows.
Borders, backgrounds and underlines, the way you always do.
The plugin draws each border once with Rough.js and writes it into the CSS as border-image.
Neighbours get different drawings, so a list of cards never looks stamped.
.card {
border: 2px solid #111111;
border-radius: 12px;
}
.card {
border: 2px solid #111111;
border-radius: 12px;
border-color: transparent;
border-image: var(--sk) 16 / 16px / 3px stretch;
}
Any width in px, square or rounded up to 32px.
One side of a border, or an hr. The ends always reach the edges.
Inline links get a line under every line of text: this link wraps over more than one line on a narrow screen.
Three presets or any number. Switch them below: the layout does not move.
subtle · normal · messy
Hover keeps the same shape in another colour.
Add --sketch-fill next to a background colour.
import sketchify from 'postcss-sketchify';
export default {
plugins: [sketchify({ roughness: 'normal' })],
};
npx sketchify style.css -o out.css npx sketchify a.css b.css -d dist npx sketchify style.css -o out.css --watch