GooseUI

Components

Corner Badge

New

A badge that sits in a card corner and looks cut into it: concave notches run along both edges next to it. The badge and the notches share one background, so a gradient flows through them without a joint.

Browser support

The photo variant uses CSS masks (mask-image, mask-composite) and the sqrt() and pow() math functions. The badge variant needs neither.

Preview

Starter kit

Everything you need to launch a small project.

Starter kit

Everything you need to launch a small project.

Installation

npx shadcn@latest add @gooseui/corner-badge
pnpm dlx shadcn@latest add @gooseui/corner-badge
yarn dlx shadcn@latest add @gooseui/corner-badge
bunx --bun shadcn@latest add @gooseui/corner-badge

Usage

The card needs position: relative. The outer corner of the badge inherits the card's border-radius, so it fits any rounding.

import { Sparkles } from "lucide-react"
import { CornerBadge } from "@/components/ui/corner-badge"

export default function Example() {
  return (
    <div className="relative rounded-2xl border bg-card p-6">
      <CornerBadge aria-hidden="true">
        <Sparkles className="size-5" />
      </CornerBadge>
      <h3 className="font-semibold">Starter kit</h3>
    </div>
  )
}

Examples

Any corner

corner takes tl, tr, bl or br.

tl
tr
bl
br
<CornerBadge corner="tl" size={40}><Star className="size-4" /></CornerBadge>
<CornerBadge corner="tr" size={40}><Heart className="size-4" /></CornerBadge>
<CornerBadge corner="bl" size={40}><Zap className="size-4" /></CornerBadge>
<CornerBadge corner="br" size={40}><ArrowUpRight className="size-4" /></CornerBadge>

Short text and colors

color picks a theme token. notch and radius control the size of the notches and the inner corner.

New
Starter kit

Everything you need to launch a small project.

-20%
Starter kit

Everything you need to launch a small project.

<div className="relative rounded-md border bg-card p-5">
  <CornerBadge color="foreground" size={44} notch={12} radius={10}>
    <span className="text-[11px] uppercase">New</span>
  </CornerBadge>
</div>

<div className="relative rounded-[2rem] border bg-card p-5">
  <CornerBadge color="destructive" size={52}>-20%</CornerBadge>
</div>

Interactive content

Put a link or a button inside. Give it rounded-[inherit] so the focus ring follows the badge shape.

Starter kit

Everything you need to launch a small project.

<CornerBadge color="secondary" size={44}>
  <a
    href="/kits/starter"
    aria-label="Open starter kit"
    className="flex size-full items-center justify-center rounded-[inherit] focus-visible:ring-[3px] focus-visible:ring-ring/50"
  >
    <ArrowUpRight className="size-5" />
  </a>
</CornerBadge>

Photo in the corner

variant="photo" cuts the corner out of the card with a CSS mask and puts an image in the cut. The cut is concentric with the photo, so the gap is even along the arc, and it works on any page background and any card color. Give the card a fill (bg-muted) and no border or shadow: the mask removes the border in the cut, so the line would break, and a shadow would show as a grey rim around the photo. Tune the geometry with --corner-photo-size, --corner-photo-gap, --corner-photo-radius and --corner-photo-fillet (plain numbers in px). Use children instead of src for initials. The mask also hides anything the card puts outside the cut, so keep other content out of the corner.

Anna Petrova
Anna Petrova

Lead instructor, strategy

Helps teams turn a vague idea into a clear plan. Runs the practice sessions and reviews final projects.

12 years · 4.9
Alex Morgan
Product design

How to write a brief in one evening

Five questions that save a week of revisions, and a template you can copy.

Alex Morgan · 6 min read · Nov 12

Canvas backpack
-18%
Canvas backpack

Waxed canvas, a padded laptop sleeve and a water-resistant base.

$89$109
Product management
Online

Product management

From a first interview to a launched product, with a final project.

6 months
48 lessons
Installments
from $99/mo
// Teacher card: fill only, no border or shadow.
// Content next to the photo is pushed by size + gap - padding (112 + 6 - 24 ≈ 104)
<div className="relative flex flex-col rounded-3xl bg-muted p-6">
  <CornerBadge
    variant="photo"
    corner="tl"
    size={112}
    gap={6}
    src="/teacher.webp"
    alt="Anna Petrova"
  />
  <div className="ml-[104px] min-h-[88px]">
    <div className="text-lg font-semibold">Anna Petrova</div>
    <p className="text-sm text-muted-foreground">Lead instructor, strategy</p>
  </div>
  <p className="mt-6 text-sm text-muted-foreground">
    Helps teams turn a vague idea into a clear plan.
  </p>
  <div className="mt-auto flex items-center justify-between pt-5">
    <span className="text-sm font-medium">12 years · 4.9</span>
    <Button size="sm">Enroll</Button>
  </div>
</div>

// Another corner: corner="tr" | "bl" | "br", then move the content padding
// to the matching side (mr, pr, pb, pl)
// Another shape: shape="rounded" with radius, e.g. a product or a course
<CornerBadge
  variant="photo"
  corner="br"
  shape="rounded"
  size={120}
  radius={28}
  src="/backpack.webp"
  alt="Canvas backpack"
/>

// Geometry through CSS variables (numbers in px) on the card
<div className="relative rounded-2xl bg-muted [--corner-photo-size:88] [--corner-photo-gap:8] [--corner-photo-fillet:20]">
  <CornerBadge variant="photo" corner="tl" src="/teacher.webp" alt="" />
</div>

Initials instead of a photo

Pass children instead of src. The cut and the gap stay the same.

AP
Anna Petrova

Instructor, no photo yet

<CornerBadge variant="photo" corner="tl" size={80}>AP</CornerBadge>

Gradient through CSS variables

--corner-badge-bg accepts any CSS background, --corner-badge-fg sets the content color. You can set them on the badge or on the card.

<CornerBadge
  size={56}
  style={{
    "--corner-badge-bg": "linear-gradient(135deg, var(--chart-1), var(--chart-4))",
    "--corner-badge-fg": "var(--background)",
  } as React.CSSProperties}
>
  <Zap className="size-6" />
</CornerBadge>

// or with Tailwind on the card
<div className="relative rounded-3xl border [--corner-badge-bg:linear-gradient(135deg,var(--chart-1),var(--chart-4))]">
  <CornerBadge><Zap /></CornerBadge>
</div>

Props

PropTypeDefaultDescription
variant"badge" | "photo""badge"badge fills the shape, photo cuts the corner and sets an image or children into it
srcstring-Image URL for the photo variant, rendered as a lazy img
altstring""Alt text of the image, empty string for decorative
shape"circle" | "rounded""circle"Shape of the inset photo
gapnumber4Even gap around the photo in px
corner"tl" | "tr" | "bl" | "br""tr"Card corner the badge sits in
sizenumber48Badge side in px
notchnumbersize × 0.4, photo: 16Radius of the concave notches in px. For photo: fillet to the card edges
radiusnumbernotch, photo: size × 0.25Radius of the inner corner in px. For a rounded photo: its radius
color"primary" | "secondary" | "muted" | "foreground" | "destructive" | "background""primary"Theme token used for the fill
childrenReactNode-Icon or short text
classNamestring-Additional CSS classes
...propsComponentProps<"div">-Any other div attributes

CSS variables

PropTypeDefaultDescription
--corner-badge-bgCSS background-Fill of the badge and notches, gradients included
--corner-badge-fgCSS color-Content color
--corner-photo-sizenumbersizePhoto side, a number in px
--corner-photo-gapnumbergapEven gap between the photo and the cut edge, px
--corner-photo-radiusnumbersize × 0.25Radius of a rounded photo, px (the circle ignores it)
--corner-photo-filletnumber16Radius of the rounded transitions to the card edges, px

Features

  • No joint: the badge and both notches share one background canvas
  • Any radius: the outer corner inherits the card's border-radius
  • Four corners: tl, tr, bl and br
  • Photo variant: a real mask cut concentric with the photo, on any background
  • Server-friendly: no client JavaScript