@klinking/squircle

We all love the squircle! It's great, we can use it to make corners feel extra smooth. Gives that little bit of zhuzh. Others can tell you all about the math and why we love it. And now we can use them in CSS! There's just one problem... for the same border-radius, the squircle will look less rounded than the circle. That's where this package comes in.

Tailwind

Explore Tailwind utilities for squircles and pills with visual examples.

Squircle Corners

Compare regular rounded-* corners with squircle squircle-* corners at several radii.

Small radius

rounded-lg
squircle-lg

Medium radius

rounded-2xl
squircle-2xl

Large radius

rounded-3xl
squircle-3xl

Squircle amount (squircle-amt-*)

Controls the superellipse exponent. Higher = more square. Default is 2.

squircle-3xl squircle-amt-1
squircle-3xl squircle-amt-1.5
squircle-3xl (default 2)
squircle-3xl squircle-amt-3
squircle-3xl squircle-amt-5

Per-corner squircles

squircle-tl-3xl
squircle-tr-3xl
squircle-br-3xl
squircle-bl-3xl
squircle-t-3xl
squircle-b-3xl

Logical-side squircles

squircle-s-3xl
squircle-e-3xl
squircle-se-3xl
squircle-es-3xl
squircle-ee-3xl
squircle-ss-3xl

Pill Shapes

Pill-shaped rectangles whose semicircular caps ease into the straight edges with no jump in curvature, or in how fast it changes (G3), drawn by a Houdini paint worklet. Browsers without the Paint API show the plain rounded-full stadium instead.

One utility, any size

squircle-pill derives the caps from the element's own size, so there is nothing to configure per size. Next to it, the plain rounded-full stadium the pill falls back to where paint worklets are unsupported.

squircle-pill
rounded-full
squircle-pill h-10 w-10
squircle-pill h-24 w-12

Arc and edge setbacks

squircle-pill-arc-setback-* selects how many degrees of the circular cap the transition replaces. squircle-pill-edge-setback-*selects how far past the arc's top it finishes, in multiples of half the pill's height. G3 is the default; squircle-pill-g2 remains available.

arc-setback-0 (stadium)
default: 45°, edge 0.75r, G3
arc-setback-60 edge-setback-1
arc-setback-30 edge-setback-2 G2

Borders, the usual way

With tailwind-pill-border loaded, Tailwind's own border-* utilities drive a ring the worklet draws along the real outline. Inset shadows and outlines need nothing special.

border-2
border-4 border-demo-corner
border-2 border-dashed border-demo-corner
shadow-inner (inset shadow)
outline-2 -outline-offset-4

Common use cases

Pill button

Pill badge

New

Pill with icon placeholder

Label

Edit on StackBlitz

Powered by StackBlitz. Requires a Chromium-based browser.