What it does
The QR code generator component takes a value (text, URL, or any data) and renders it as a QR code using a canvas element. You can configure the error correction level, pixel size, colors, and margin. An optional caption can be displayed below the QR code.
The component supports an animated variant with entrance animations like fade-in, zoom-in, slide-up, and rotate-in when using framer-motion.
Composition and API
Pass the data to encode via the required value prop. Configure the appearance with size (sm/md/lg) and appearance variants. Use canvasSize to control the pixel dimensions of the generated QR code. The level prop sets error correction, and bgColor/fgColor control colors.
Common use cases
QR codes are widely used for URL sharing, Wi-Fi credentials, contact information, payment links, and product identification. The generator is ideal for marketing pages, admin dashboards, event ticketing systems, and any application that needs to encode data for mobile scanning.
Accessibility
The canvas element includes an aria-label describing the encoded value. The component uses semantic HTML structure and data-slot attributes for styling targets. The animated variant respects reduced motion preferences.
Next.js integration notes
Colocate examples under the App Router, keep server and client boundaries explicit, and avoid pulling interactive components into unexpected server layouts.
Set NEXT_PUBLIC_SITE_URL so canonical and Open Graph URLs resolve on deploy.
FAQ
Does the QR Code component work with Next.js App Router?
Yes. Import it like any other React component; the component uses client-side rendering with canvas and works seamlessly with server components when used as a client boundary.
Can I customize QR code colors?
Yes. Use the bgColor and fgColor props to customize the background and foreground colors. The component supports any valid CSS color value.
What error correction levels are available?
The component supports L (7%), M (15%), Q (25%), and H (30%) error correction levels. Higher levels allow more damage before the code becomes unreadable but reduce data capacity.
Is there a maximum data size?
Yes, QR codes have a maximum data capacity depending on the error correction level and version. For level M, a Version 40 QR code can hold up to 4,296 alphanumeric characters.