Pill gallery
Compare shadows with plain Tailwind →
Every pill below is squircle-pill h-12 w-40 bg-indigo-500 plus the classes in its label,
unless its section says otherwise.
Switch modes to compare how each is drawn; each loads the page afresh. The notes describe a
shaped pill: with no shaping each is a plain stadium, so what the shape would erase still
shows.
Drawn by …
Sides
A side caps that end alone and squares the other. -s and -e are the inline ends, so they swap right to left. There are no -x or -y: a cap can't be wider than the box, so squircle-pill always caps the short ends.
-
(no classes)
Both short ends, chosen from the aspect ratio.
-
squircle-pill-l
The left end, the same cap as a full pill's.
-
squircle-pill-r
The right end.
-
squircle-pill-t
The top: a tab whose corners run the full height.
-
squircle-pill-b
The bottom.
-
squircle-pill-s
The inline start: the left here.
-
squircle-pill-e
The inline end: the right here.
-
squircle-pill-s · dir=rtl
Right to left, the start is the right.
-
squircle-pill-e · dir=rtl
Right to left, the end is the left.
Sides on tall and square pills
The same utilities on a pill taller than it is wide, and on a square. A cap is clamped to what the box can give it, so a square capped at one end is an arch, not a circle.
-
(no classes)
Tall: caps top and bottom.
-
squircle-pill-t
The top end alone.
-
squircle-pill-b
The bottom end alone.
-
squircle-pill-l
The left, clamped to the width.
-
squircle-pill-r
The right, clamped to the width.
-
(no classes)
Square: a circle.
-
squircle-pill-t
Square, top only: an arch.
-
squircle-pill-l
Square, left only.
Button groups
What sides are for: the first button capped at the start, the last at the end, the middle square. The same markup right to left caps the other way round.
-
squircle-pill-s · (square) · squircle-pill-e
Left to right.
-
squircle-pill-s · (square) · squircle-pill-e · dir=rtl
The same markup, right to left.
-
squircle-pill-s · (square) · squircle-pill-e
With a border on each button.
Backgrounds
The pill hides the element's own background and paints a copy of it shaped to the pill, so any background works: colours, gradients, images, translucency.
-
bg-linear-to-r from-indigo-500 to-pink-500
A linear gradient.
-
bg-conic-210 from-amber-400 via-violet-500 to-amber-400
A conic gradient.
-
bg-[repeating-conic-gradient(#0ea5e9_0_25%,#f59e0b_0_50%)] bg-size-[28px_28px]
A repeating image, positioned against the box as usual.
-
bg-indigo-500/40
Translucent, so the page shows through.
Clip paths of its own
The pill shapes a copy of its background rather than the element itself, so the element's own clip-path applies on top of it, border and all, with the worklet and the polyfill alike.
-
[clip-path:inset(0_0_0_50%)]
The right half of the pill.
-
[clip-path:polygon(0_0,100%_0,0_100%)]
The pill's top-left triangle.
-
[clip-path:circle(40%_at_100%_50%)]
A lens: the pill inside a circle centred on its right edge.
-
[clip-path:inset(6px_round_10px)]
The pill inside a rounded rectangle 6px in from each edge.
Tailwind mask utilities
A mask on the element applies to the whole pill, as it would to any element: the shape is on the copy of its background, so the two never compete.
-
mask-b-from-20%
Fades out towards the bottom.
-
mask-r-from-40%
Fades out towards the right.
-
mask-radial-from-40%
Fades out from the centre.
Borders
Drawn by the pill along its own outline, from Tailwind's border utilities, with tailwind-pill-border loaded.
-
border-2 border-white
A solid ring along the outline.
-
border-4 border-dashed border-amber-300
Dashes along the outline.
-
border-2 border-dotted border-white
Dots along the outline.
-
border-2
Width only: the colour defaults to currentColor, as a real border's does.
- Label
border-2 border-violet-300
A pill inside a bordered pill draws no border of its own.
Outlines
Drawn by the pill along its own outline, with tailwind-pill-border loaded: offset outwards, or inwards with a negative offset, solid, dashed or dotted.
-
outline-2 outline-white
Hugging the outline.
-
outline-2 outline-offset-4 outline-white
Offset 4px out.
-
outline-2 outline-offset-2 outline-dashed outline-amber-300
Dashed, offset 2px out.
-
outline-2 -outline-offset-2 outline-white
Inset 2px, just inside the edge.
-
outline-2 -outline-offset-6 outline-white
Inset 6px.
Tailwind ring utilities
Drawn by the pill along its own outline too, with tailwind-pill-border loaded. A ring offset is a band of its own colour, as in Tailwind.
-
ring-2 ring-white
A ring hugging the outline.
-
ring-2 ring-white ring-offset-2 ring-offset-zinc-950
With a 2px offset in the page's colour.
-
ring-4 ring-amber-300/60
Semi-transparent, so the background shows through.
-
inset-ring-2 inset-ring-white
An inset ring, inside the edge.
Focus
Tab through these. The pill picks up focus states like any other, outside the box included; with no utility at all the browser's own focus ring shows, around the stadium.
-
focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white
An offset outline on keyboard focus.
-
focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-offset-2 focus-visible:ring-offset-zinc-950
A ring with an offset on keyboard focus.
-
(no classes)
The browser's own focus ring.
Shadows
Box shadows are cast by the pill's own outline, so they meet it with no gap. A drop shadow follows the pill-shaped background by itself; inner shadows are painted inside the pill. Shown on light tiles so the shadows stand out.
-
shadow-xl shadow-black/60
A box shadow.
-
drop-shadow-xl drop-shadow-black/60
A drop shadow filter.
-
shadow-inner shadow-black/80
An inner shadow.
-
inset-shadow-sm inset-shadow-black/80
An inset shadow.
-
shadow-lg shadow-black/50 ring-2 ring-white
A shadow under a ring.
-
bg-linear-to-r from-blue-700 to-violet-600 border-4 border-zinc-900 outline-2 -outline-offset-8 outline-white/60 drop-shadow-xl drop-shadow-black/60
A gradient, a border, an inset outline and a drop shadow, all at once.
Without Tailwind
The plain-CSS stylesheet, squircle-pill.css, on data-squircle-pill elements, driven by the pill's own custom properties. Each label is the element's inline style.
-
--squircle-pill-border-width: 3px; --squircle-pill-border-color: #fbbf24; --squircle-pill-border-style: dashed
A dashed border.
-
--squircle-pill-border-width: 0.2rem
Width only: currentColor, and any length unit.
-
--squircle-pill-ring-width: 2px; --squircle-pill-ring-color: #fff; --squircle-pill-ring-offset-width: 2px; --squircle-pill-ring-offset-color: #09090b
A ring beyond an offset band.
-
--squircle-pill-outline-width: 2px; --squircle-pill-outline-offset: -6px; --squircle-pill-outline-color: #fff
An inset outline.
-
--squircle-pill-box-shadow: 0 8px 16px rgb(0 0 0 / 0.6)
A box shadow; initialization reserves its painting space automatically.
-
data-squircle-pill="t"
Capped at the top, from the attribute alone.
-
data-squircle-pill="l"
Capped at the left.
-
data-squircle-pill="e"
Capped at the inline end.
-
data-squircle-pill="e" · dir=rtl
The inline end, right to left.