# Choose module and eye shapes (Features)

URL: https://qrdx.dev/docs/features/patterns
Source: https://github.com/qrdxinc/qrdx/blob/main/apps/docs/content/docs/features/patterns.mdx

Set the shapes of the modules, corner eyes and eye centers in code, scale the modules, fit the code in a circle, a heart or your own outline, color each eye.

Three props shape a code: `bodyPattern` for the data modules, `cornerEyePattern` for the three corner eyes and `cornerEyeDotPattern` for the dot inside each eye. This page covers them, plus module scale, shaped codes and per-eye colors. Every value is drawn live in [Shapes, eyes and frames](https://qrdx.dev/docs/styles).

Designing in the playground or the dashboard instead? Start with [Make your first QR code](https://qrdx.dev/docs/help/getting-started/first-qr-code) in Help.

```tsx title="components/shaped-code.tsx"
import { QRCode } from "qrdx";

export function ShapedCode() {
  return (
    <QRCode
      value="https://example.com"
      size={256}
      bodyPattern="liquid"
      cornerEyePattern="leaf"
      cornerEyeDotPattern="leaf"
    />
  );
}
```

## Body patterns [#body-patterns]

`bodyPattern` shapes the data modules. There are 25 values; the default is `circle`.

- Classic: `square`, `small-square`, `horizontal-line`, `vertical-line`, `octagon`, `pixel`
- Rounded: `circle`, `circle-large`, `rounded`, `liquid`, `liquid-horizontal`, `liquid-vertical`, `random-dots`
- Decorative: `classy`, `classy-rounded`, `leaf`, `diamond`, `hexagon`, `stitch`
- Playful: `mosaic`, `plus`, `star`, `heart`, `pacman`, `circle-mixed`

`liquid`, `classy`, `classy-rounded` and `pixel` join neighboring modules into one outline (`pixel` cuts the corners in square steps, like a bitmap, instead of rounding them); `liquid-horizontal` and `liquid-vertical` join them in rows or columns only. `stitch` draws each module as a bold cross-stitch whose strokes touch at the corners, like embroidery. `random-dots` and `mosaic` vary per module but always draw the same code for the same value. Alignment patterns are always drawn as solid squares, whatever the pattern, so decoders find them.

### Module scale [#module-scale]

`moduleScale` (0.5 to 1, default 1) shrinks each data module around its center for a lighter, more spaced look. Connected patterns get thinner lines instead. Each pattern stops shrinking at the smallest size that still decodes in the package's tests (for example 0.95 for `circle`, 0.7 for `classy`; the floors are exported as `MODULE_SCALE_FLOOR`), and alignment patterns keep full size.

```tsx title="components/light-code.tsx"
import { QRCode } from "qrdx";

export function LightCode() {
  return (
    <QRCode
      value="https://example.com"
      bodyPattern="liquid"
      moduleScale={0.8}
    />
  );
}
```

## Finishes [#finishes]

`finish` changes how each data module and the finder eyes are surfaced, on top of any body pattern, eye shape and colour: `flat` (the default), `gloss` (a light spot and a darker lower edge on each dot), `clay` (a soft pillow with a lighter centre and a drop shadow), `keycap` (a lighter top face raised on a darker base), `studs` (a round stud on each dot) or `blocks` (side faces down and to the right, like stacked blocks). Every finish is drawn live in [Shapes, eyes and frames](https://qrdx.dev/docs/styles#finishes).

```tsx title="components/glossy-code.tsx"
import { QRCode } from "qrdx";

export function GlossyCode() {
  return (
    <QRCode
      value="https://example.com"
      size={256}
      bodyPattern="rounded"
      fgColor="#1d4ed8"
      finish="gloss"
    />
  );
}
```

- A finish is a few flat vector layers in shades of the dots' colour, one merged `<path>` per shade, so the SVG, PNG, PDF and EPS outputs paint the same picture and a code gains a handful of elements rather than one per module. `QRCodeCanvas` ignores it.
- The shades come from the colour's OKLab lightness, so a finish works with any solid colour and with gradients (each stop is shaded). An image fill stays flat.
- The finder eyes take the finish in shades of their own colours (`eyeColor`, `dotColor`, per-eye colours), with every layer inside the eye's outline so the light gaps decoders need stay exactly as wide as flat: a highlight band along the middle of the frame and a smaller copy of the centre, studs a module apart, or a top face over side faces. On the eyes the shades stay within 20 grey levels of the eye's colour, and gloss shows its spot without the lower edge. In the package's decode tests every finish reads with every eye frame and every eye centre, on plain dots and on a palette, wherever the same code reads drawn flat. With the cushion frame and the rounded-triangle centre together, `keycap` and `studs` aren't drawn at all and the code stays flat: with that pair, jsQR missed a read at 4 pixels per module under either finish that it makes on the flat code, and no way of drawing them fixed it. The scan score's `finish` check says so. What stays flat: eye shapes a finish lost a read on (for example the diya-reverse and message-reverse centres under gloss, or the default gear frame and circle centre under blocks), frames too thin for a highlight a quarter module from their edges (gear, porthole and notch under gloss and clay; plus, bud and bowl too under clay), eyes lighter than the background, retired shapes, and every eye under `keycap`, whose plate and top lost reads on one eye shape after another.
- Every shade keeps the scan score's contrast line (4.5:1) against the background: a highlight is moved back toward the dots' colour until it does, so a finish never costs a readable colour its contrast. In the package's decode tests every finish reads with every body pattern wherever the flat body reads, through the camera model at 4, 6 and 9 pixels per module and drawn sharp, with jsQR and ZXing, in black, brand colours, a mid-tone and light-on-dark. Dots that are already too light for any shade keep their colour, and the scan score's `finish` check says so (`getFinishRisk`).
- `blocks` reaches `BLOCK_DEPTH` (0.2) of a module into the gaps, less than the shadow look's largest shift. A halo or a shadow copies the finish's footprint, and a circle or heart code's decorative modules take the finish too. Under `blocks` a shadow is drawn closer and lighter, and not at all with circle-mixed, pacman or star dots ([Effects](https://qrdx.dev/docs/features/effects#shadow)).

## Eye frames [#eye-frames]

`cornerEyePattern` shapes the corner eyes. There are 22 values; the default is `gear`: `square`, `rounded`, `extra-rounded`, `squircle`, `cushion`, `bevel`, `octagon`, `leaf`, `leaf-reverse`, `drop`, `petal`, `shield`, `gear`, `circle`, `diya`, `message`, `pointy`, `porthole`, `notch`, `plus`, `bud` and `bowl`.

`leaf`, `leaf-reverse`, `drop`, `petal` and `bud` turn each of the three eyes to face its corner of the code. `circle` eyes may be missed by some scanner apps; the [scan score](https://qrdx.dev/docs/features/frames#will-it-scan) warns about them.

`porthole`, `notch`, `plus`, `bud` and `bowl` cut or round every corner. With the default body, `circle`, `rounded`, `squircle` and `cushion` centres read inside them in the package's sharp-render tests; `square`, `diya` and `rounded-triangle` centres are missed by strict decoders in many sharp renders and `heart` in some, as they are in `gear` and `octagon` eyes. The playground pairs each of these eyes with a centre that reads.

## Eye centers [#eye-centers]

`cornerEyeDotPattern` shapes the dot inside each eye. There are 22 values; the default is `circle`: `square`, `rounded`, `extra-rounded`, `circle`, `squircle`, `octagon`, `hexagon`, `dots`, `leaf`, `leaf-reverse`, `drop`, `drop-reverse`, `plus`, `cross-rounded`, `flower`, `heart`, `message`, `message-reverse`, `diya`, `diya-reverse`, `rounded-triangle` and `cushion`.

## Pairs to avoid and retired shapes [#pairs-to-avoid-and-retired-shapes]

`diamond` bodies next to `square` eyes, `pacman` next to `rounded`, and `small-square` next to `square` or `rounded` eyes are missed up close. The playground does not combine them, they ship as `WEAK_BODY_EYES`, and `getStylePairRisk(props)` returns the warning the scan score shows.

A `circle` center inside eyes with square corners (`square`, `rounded`, `extra-rounded` and most others) can be missed by strict decoders in sharp renders: on screens, in PNG exports and in large prints. Solid bodies (`square`, `liquid`, `classy`, `classy-rounded`) usually still read, and `gear`, `circle` and `octagon` eyes are unaffected. The scan score warns about it (`style-pair`) and you can still pick it. The pairs ship as `WEAK_SHARP_DOT_EYES` (with `SHARP_DOT_EYE_SAFE_BODIES`), and a `rounded` center avoids the problem.

`curly` eyes and `diamond`, `star` and `banner` centers were retired because they do not scan reliably. Designs saved with them still render, but they are no longer offered or listed; see [Retired shapes](https://qrdx.dev/docs/styles#retired-shapes).

## Circle codes [#circle-codes]

`shape="circle"` puts the code in a disc and fills the rest of it with decorative modules in the same dot shape. The real code keeps a light ring of `margin` modules around it (at least 3), and scanners read only the code in the middle. The disc is bigger than the code, so print it a little larger for the same scan distance; the [print size calculator](https://qrdx.dev/tools/print-size) counts the whole disc.

```tsx title="components/circle-code.tsx"
import { QRCode } from "qrdx";

export function CircleCode() {
  return (
    <QRCode
      value="https://example.com"
      size={256}
      shape="circle"
      bodyPattern="rounded"
    />
  );
}
```

In the package's decode tests circle codes read like square ones with solid dot shapes (`square`, `rounded`, `classy`, `liquid`).

![Two shaped codes with rounded modules: on the left a circle code, the QR code in the middle of a disc filled with decorative modules, and on the right a heart code, the same inside a heart outline.](https://qrdx.dev/docs-static/shots/lib-circle-code.light.webp)

## Heart codes [#heart-codes]

`shape="heart"` works like a circle code, in a heart. The real code sits in the middle of the heart with its light ring of at least 3 modules, and the rest of the heart fills with decorative modules. The code takes a smaller part of a heart than of a circle, so print a heart code larger than a square one for the same scan distance. The scan score counts this: at the same size, a heart code scores lower than a circle code.

```tsx title="components/heart-code.tsx"
import { QRCode } from "qrdx";

export function HeartCode() {
  return (
    <QRCode
      value="https://example.com"
      size={256}
      shape="heart"
      bodyPattern="rounded"
    />
  );
}
```

A shaped code takes the place of a frame in the playground: picking one clears the frame, and picking a frame clears the shape. Every frame paints a light plate under the code, which would hide the outline. The engine still draws `shape` with a `frame` if you pass both. In the package's decode tests heart codes read with every solid dot shape and with `square`, `rounded` and `gear` eyes.

## Custom shapes [#custom-shapes]

`shape` also takes a silhouette: a small grid traced from a picture of your own (at most 64 cells a side). The code sits in the roomiest middle part of the shape, and the rest of the shape fills with decorative modules. Only the grid is kept, never the picture.

```tsx title="components/silhouette-code.tsx"
import { getQRSilhouetteFit, loadQRSilhouette, QRCode } from "qrdx";

export async function silhouetteFrom(file: File) {
  const shape = await loadQRSilhouette(file); // a PNG, JPEG or SVG, in the browser
  const fit = getQRSilhouetteFit(shape);
  if (!fit.ok) throw new Error(fit.message);
  return shape;
}

export function SilhouetteCode({ shape }: { shape: Awaited<ReturnType<typeof silhouetteFrom>> }) {
  return <QRCode value="https://example.com" size={256} shape={shape} />;
}
```

`loadQRSilhouette` draws the picture on a canvas and uses its transparency, or its darkness when it is opaque, so a light shape on a dark background works too. On a server, pass decoded RGBA pixels to `createQRSilhouette`. `getQRSilhouetteFit` refuses a shape that is too thin to hold the code with its quiet zone, such as a thin star, a bar or a ring. A refused shape draws as a square code.

In the dashboard a silhouette stays with the design, like an uploaded logo: shared links, community items, code snippets and the AI chat use a square code instead.

## Per-eye shapes [#per-eye-shapes]

`eyeShapes` gives each of the three eyes its own frame and center shape: `topLeft`, `topRight` and `bottomLeft`, each with an `outer` (an eye frame) and an `inner` (an eye center). An eye you leave out keeps `cornerEyePattern` and `cornerEyeDotPattern`.

```tsx title="components/eye-shapes-code.tsx"
import { QRCode } from "qrdx";

export function EyeShapesCode() {
  return (
    <QRCode
      value="https://example.com"
      size={256}
      cornerEyePattern="rounded"
      cornerEyeDotPattern="rounded"
      eyeShapes={{
        topLeft: { outer: "leaf", inner: "leaf" },
        bottomLeft: { inner: "dots" },
      }}
    />
  );
}
```

Each eye is judged on its own: the [scan score](https://qrdx.dev/docs/features/frames#will-it-scan) checks every eye's frame and center with the dot shape, and warns about the worst pair, as it does for one `cornerEyePattern`. One `circle` eye counts as circle eyes. The playground's Eye shapes section offers, for each eye, only the shapes that scan with the rest of the design.

## Per-eye colors [#per-eye-colors]

`eyeColor` and `dotColor` color all three eyes. `eyeColors` overrides them per eye (`topLeft`, `topRight`, `bottomLeft`), each with an `outer` (frame) and `inner` (dot) color or gradient:

```tsx title="components/eye-colors-code.tsx"
import { QRCode } from "qrdx";

export function EyeColorsCode() {
  return (
    <QRCode
      value="https://example.com"
      size={256}
      eyeColor="#111827"
      eyeColors={{
        topLeft: { outer: "#dc2626", inner: "#1d4ed8" },
        topRight: { outer: "#16a34a" },
      }}
    />
  );
}
```

Keep every eye dark against the background: decoders find the code by its three eyes. The scan score checks each eye's own colors for contrast.

## Related [#related]

- [Shapes, eyes and frames](https://qrdx.dev/docs/styles): Every value drawn live, with the pairs to avoid.
- [Set colors and gradients](https://qrdx.dev/docs/features/colors-gradients): Colors for the modules, eyes and background.
- [Frames, scan score and print files](https://qrdx.dev/docs/features/frames): Check a design before you print it.
- [Library API reference](https://qrdx.dev/docs/api-reference): The pattern types and every exported constant.
