For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms-full.txt, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/v/0.6.0/en/components/qr-code.md.
  • English
  • QRCode

    Present text and links as QR codes.

    Basic usage

    QR code
    basic.tsx
    import { QRCode } from '@ifhover/leaf-ui';
    
    export function QRCodeBasic() {
      return <QRCode value="https://ifhover.github.io/leaf-ui/" downloadable />;
    }
    

    More examples

    Loading
    QR code
    Refresh after expiry
    QR code
    Custom color
    QR code
    advanced.tsx
    import { Flex, QRCode, Space, Text } from '@ifhover/leaf-ui';
    
    import { useState } from 'react';
    
    export function QRCodeStatus() {
      const [expired, setExpired] = useState(true);
      return (
        <Flex gap="md" align="center" wrap justify="center">
          <Space direction="vertical" align="stretch">
            <Text tone="muted">Loading</Text>
            <QRCode value="Leaf UI" size={140} status="loading" />
          </Space>
          <Space direction="vertical" align="stretch">
            <Text tone="muted">Refresh after expiry</Text>
            <QRCode
              value="Leaf UI"
              size={140}
              status={expired ? 'expired' : 'active'}
              onRefresh={() => setExpired(false)}
            />
          </Space>
          <Space direction="vertical" align="stretch">
            <Text tone="muted">Custom color</Text>
            <QRCode value="Leaf UI" size={140} color="#2463eb" />
          </Space>
        </Flex>
      );
    }
    

    Usage

    value contains the encoded content. status can display a loading or expired state. Handle refresh through onRefresh and enable downloadable for SVG downloads.

    Types

    Import these types for data, callbacks and refs.

    import type { QRCodeProps } from '@ifhover/leaf-ui';

    QRCodeProps API

    PropertyTypeDefaultDescription
    valuestringRequiredControlled value
    sizenumber160Size or spacing preset
    colorstring'var(--leaf-color-text)'Color
    backgroundColorstring'var(--leaf-color-surface)'Background color
    level'L' | 'M' | 'Q' | 'H''M'QR error correction level
    logostring—Center logo URL
    logoSizenumber32Center logo size
    status'active' | 'loading' | 'expired''active'Display state
    onRefresh() => void—Refresh expired QR code
    downloadablebooleanfalseShow download action
    fileNamestring'qrcode.svg'Download filename