A PostCSS plugin

Sketch your CSS.
Keep your layout.

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

Three promises

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.

How it works

  1. 1

    Write plain CSS

    Borders, backgrounds and underlines, the way you always do.

  2. 2

    Build

    The plugin draws each border once with Rough.js and writes it into the CSS as border-image.

  3. 3

    Ship sketches

    Neighbours get different drawings, so a list of cards never looks stamped.

You write
.card {
  border: 2px solid #111111;
  border-radius: 12px;
}
You get
.card {
  border: 2px solid #111111;
  border-radius: 12px;
  border-color: transparent;
  border-image: var(--sk) 16 / 16px / 3px stretch;
}

What gets drawn

Borders

Any width in px, square or rounded up to 32px.

1px 2px 4px 12px

Single lines

One side of a border, or an hr. The ends always reach the edges.

  • Dividers in a list
  • However long it gets
  • Still reach both ends

Roughness

Three presets or any number. Switch them below: the layout does not move.


subtle · normal · messy

States

Hover keeps the same shape in another colour.

Fills

Add --sketch-fill next to a background colour.

rough marker hatch

Use it

postcss.config.js
import sketchify from 'postcss-sketchify';

export default {
  plugins: [sketchify({ roughness: 'normal' })],
};
Command line
npx sketchify style.css -o out.css
npx sketchify a.css b.css -d dist
npx sketchify style.css -o out.css --watch
OptionDefaultWhat it does
roughness'normal''subtle', 'normal', 'messy' or a number.
hatch'normal''fine', 'normal', 'bold' or your own numbers.
quiet[]Warning kinds to leave out.
budget{ gzip: 30 }Warn when drawings add more KB than this.

Good to know

roughness