Skip to content
UI

QR Code

A component that generates and displays QR codes.

<script setup lang="ts">
import { QrCode } from '@destyler-ui/vue'
</script>

<template>
  <QrCode.Root value="http://destyler.com">
    <QrCode.Frame>
      <QrCode.Pattern />
    </QrCode.Frame>
    <QrCode.Overlay>
      <img src="https://github.com/elonehoo.png" alt="" />
    </QrCode.Overlay>
    <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">Download</QrCode.DownloadTrigger>
  </QrCode.Root>
</template>
import { QrCode } from '@destyler-ui/react'

export function Basic() {
  return (
    <QrCode.Root value="https://destyler.com">
      <QrCode.Frame>
        <QrCode.Pattern data-testid="pattern" />
      </QrCode.Frame>
      <QrCode.Overlay>
        <img src="https://github.com/elonehoo.png" alt="" />
      </QrCode.Overlay>
      <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">
        Download
      </QrCode.DownloadTrigger>
    </QrCode.Root>
  )
}
import { QrCode } from '@destyler-ui/solid/qr-code'

export function Basic() {
  return (
    <QrCode.Root value="http://ui-ui.com">
      <QrCode.Frame>
        <QrCode.Pattern />
      </QrCode.Frame>
      <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">
        Download
      </QrCode.DownloadTrigger>
    </QrCode.Root>
  )
}
<script lang="ts">
  import { QrCode } from '@destyler-ui/svelte'
</script>

<QrCode.Root value="https://destyler.com">
  <QrCode.Frame><QrCode.Pattern data-testid="pattern" /></QrCode.Frame>
  <QrCode.Overlay><img src="https://github.com/elonehoo.png" alt="" /></QrCode.Overlay>
  <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">Download</QrCode.DownloadTrigger>
</QrCode.Root>
<script setup lang="ts">
import { QrCode } from '@destyler-ui/vue'
</script>
<template>
<QrCode.Root>
<QrCode.Frame>
<QrCode.Pattern />
</QrCode.Frame>
<QrCode.Overlay />
<QrCode.DownloadTrigger />
</QrCode.Root>
</template>
import { QrCode } from '@destyler-ui/react'
export default function Basic() {
return (
<QrCode.Root>
<QrCode.Frame>
<QrCode.Pattern />
</QrCode.Frame>
<QrCode.Overlay />
<QrCode.DownloadTrigger />
</QrCode.Root>
)
}
import { QrCode } from '@destyler-ui/solid'
export default function Basic() {
return (
<QrCode.Root>
<QrCode.Frame>
<QrCode.Pattern />
</QrCode.Frame>
<QrCode.Overlay />
<QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png" />
</QrCode.Root>
)
}
<script lang="ts">
import { QrCode } from '@destyler-ui/svelte'
</script>
<QrCode.Root value="https://destyler.com">
<QrCode.Frame><QrCode.Pattern data-testid="pattern" /></QrCode.Frame>
<QrCode.Overlay><img src="https://github.com/elonehoo.png" alt="" /></QrCode.Overlay>
<QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">Download</QrCode.DownloadTrigger>
</QrCode.Root>
<script setup lang="ts">
import { QrCode } from '@destyler-ui/vue'
</script>

<template>
  <QrCode.Root value="http://destyler.com">
    <QrCode.Frame>
      <QrCode.Pattern />
    </QrCode.Frame>
    <QrCode.Overlay>
      <img src="https://github.com/elonehoo.png" alt="" />
    </QrCode.Overlay>
    <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">Download</QrCode.DownloadTrigger>
  </QrCode.Root>
</template>
import { QrCode } from '@destyler-ui/react'

export function Basic() {
  return (
    <QrCode.Root value="https://destyler.com">
      <QrCode.Frame>
        <QrCode.Pattern data-testid="pattern" />
      </QrCode.Frame>
      <QrCode.Overlay>
        <img src="https://github.com/elonehoo.png" alt="" />
      </QrCode.Overlay>
      <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">
        Download
      </QrCode.DownloadTrigger>
    </QrCode.Root>
  )
}
import { QrCode } from '@destyler-ui/solid/qr-code'

export function Basic() {
  return (
    <QrCode.Root value="http://ui-ui.com">
      <QrCode.Frame>
        <QrCode.Pattern />
      </QrCode.Frame>
      <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">
        Download
      </QrCode.DownloadTrigger>
    </QrCode.Root>
  )
}
<script lang="ts">
  import { QrCode } from '@destyler-ui/svelte'
</script>

<QrCode.Root value="https://destyler.com">
  <QrCode.Frame><QrCode.Pattern data-testid="pattern" /></QrCode.Frame>
  <QrCode.Overlay><img src="https://github.com/elonehoo.png" alt="" /></QrCode.Overlay>
  <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">Download</QrCode.DownloadTrigger>
</QrCode.Root>

Control the QR code value programmatically.

<script setup lang="ts">
import { QrCode } from '@destyler-ui/vue'
import { ref } from 'vue'

const value = ref('https://destyler.org')
</script>

<template>
  <QrCode.Root v-model="value">
    <QrCode.Frame>
      <QrCode.Pattern />
    </QrCode.Frame>
    <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">Download</QrCode.DownloadTrigger>
  </QrCode.Root>
</template>
import { useState } from 'react'
import { QrCode } from '@destyler-ui/react'

export function Controlled() {
  const [value, setValue] = useState('https://destyler.org')

  return (
    <QrCode.Root value={value} onValueChange={({ value }) => setValue(value)}>
      <QrCode.Frame>
        <QrCode.Pattern />
      </QrCode.Frame>
      <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">
        Download
      </QrCode.DownloadTrigger>
    </QrCode.Root>
  )
}
import { QrCode } from '@destyler-ui/solid/qr-code'
import { createSignal } from 'solid-js'

export function Controlled() {
  const [value, setValue] = createSignal('http://ui-ui.com')

  return (
    <QrCode.Root value={value()} onValueChange={e => setValue(e.value)}>
      <QrCode.Frame>
        <QrCode.Pattern />
      </QrCode.Frame>
    </QrCode.Root>
  )
}
<script lang="ts">
  import { QrCode } from '@destyler-ui/svelte'
  let value = $state('https://destyler.org')
</script>

<QrCode.Root bind:value>
  <QrCode.Frame><QrCode.Pattern /></QrCode.Frame>
  <QrCode.DownloadTrigger fileName="qr-code.png" mimeType="image/png">Download</QrCode.DownloadTrigger>
</QrCode.Root>

Configure the error correction level.

<script setup lang="ts">
import { QrCode } from '@destyler-ui/vue'
import { ref } from 'vue'

const encoding = ref<QrCode.GenerateOptions>({ ecc: 'H' })
</script>

<template>
  <QrCode.Root defaultValue="https://destyler.org" :encoding="encoding">
    <QrCode.Frame>
      <QrCode.Pattern />
    </QrCode.Frame>
  </QrCode.Root>
</template>
import { QrCode } from '@destyler-ui/react'

export function ErrorCorrection() {
  return (
    <QrCode.Root
      defaultValue="https://destyler.org"
      encoding={{ ecc: 'H' }}
    >
      <QrCode.Frame>
        <QrCode.Pattern />
      </QrCode.Frame>
    </QrCode.Root>
  )
}
import { QrCode } from '@destyler-ui/solid/qr-code'

export function ErrorCorrection() {
  return (
    <QrCode.Root defaultValue="http://ui-ui.com" encoding={{ ecc: 'H' }}>
      <QrCode.Frame>
        <QrCode.Pattern />
      </QrCode.Frame>
    </QrCode.Root>
  )
}
<script lang="ts">
  import { QrCode } from '@destyler-ui/svelte'
  const encoding: QrCode.GenerateOptions = { ecc: 'H' }
</script>

<QrCode.Root defaultValue="https://destyler.org" {encoding}>
  <QrCode.Frame><QrCode.Pattern /></QrCode.Frame>
</QrCode.Root>

Display an overlay image on the QR code.

<script setup lang="ts">
import { QrCode } from '@destyler-ui/vue'
</script>

<template>
  <QrCode.Root defaultValue="https://destyler.org">
    <QrCode.Frame>
      <QrCode.Pattern />
    </QrCode.Frame>
    <QrCode.Overlay>
      <img src="https://destyler.org/favicon.svg" alt="Logo" />
    </QrCode.Overlay>
  </QrCode.Root>
</template>
import { QrCode } from '@destyler-ui/react'

export function WithOverlay() {
  return (
    <QrCode.Root defaultValue="https://destyler.org">
      <QrCode.Frame>
        <QrCode.Pattern />
      </QrCode.Frame>
      <QrCode.Overlay>
        <img src="https://destyler.org/favicon.svg" alt="Logo" />
      </QrCode.Overlay>
    </QrCode.Root>
  )
}
import { QrCode } from '@destyler-ui/solid/qr-code'

export function WithOverlay() {
  return (
    <QrCode.Root defaultValue="http://ui-ui.com">
      <QrCode.Frame>
        <QrCode.Pattern />
      </QrCode.Frame>
      <QrCode.Overlay>
        <img src="https://ui-ui.com/icon-192.png" alt="Destyler UI Logo" />
      </QrCode.Overlay>
    </QrCode.Root>
  )
}
<script lang="ts">
  import { QrCode } from '@destyler-ui/svelte'
</script>

<QrCode.Root defaultValue="https://destyler.org">
  <QrCode.Frame><QrCode.Pattern /></QrCode.Frame>
  <QrCode.Overlay><img src="https://destyler.org/favicon.svg" alt="Logo" /></QrCode.Overlay>
</QrCode.Root>
<script setup lang="ts">
import { QrCode, useQrCode } from '@destyler-ui/vue'

const qrCode = useQrCode({ defaultValue: 'https://destyler.org' })
</script>

<template>
  <button @click="qrCode.setValue('https://destyler.org')">Set Value</button>

  <QrCode.RootProvider :value="qrCode">
    <QrCode.Frame>
      <QrCode.Pattern />
    </QrCode.Frame>
  </QrCode.RootProvider>
</template>
import { QrCode, useQrCode } from '@destyler-ui/react'

export function RootProvider() {
  const qrCode = useQrCode({ defaultValue: 'https://destyler.org' })

  return (
    <>
      <button onClick={() => qrCode.setValue('https://elonehoo.me')}>
        Set Value
      </button>

      <QrCode.RootProvider value={qrCode}>
        <QrCode.Frame>
          <QrCode.Pattern />
        </QrCode.Frame>
      </QrCode.RootProvider>
    </>
  )
}
import { QrCode, useQrCode } from '@destyler-ui/solid/qr-code'

export function RootProvider() {
  const qrCode = useQrCode({ defaultValue: 'http://ui-ui.com' })

  return (
    <>
      <button onClick={() => qrCode().setValue('https://ui-ui().com')}>Set Value</button>

      <QrCode.RootProvider value={qrCode}>
        <QrCode.Frame>
          <QrCode.Pattern />
        </QrCode.Frame>
      </QrCode.RootProvider>
    </>
  )
}
<script lang="ts">
  import { QrCode, useQrCode } from '@destyler-ui/svelte'
  const id = $props.id()
  const qrCode = useQrCode({ id, defaultValue: 'https://destyler.org' })
</script>

<button type="button" onclick={() => qrCode().setValue('https://elonehoo.me')}>Set Value</button>
<QrCode.RootProvider value={qrCode}>
  <QrCode.Frame><QrCode.Pattern /></QrCode.Frame>
</QrCode.RootProvider>

Root

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

defaultValuestring

The initial value of the tabs when it is first rendered. Use when you do not need to control the state of the tabs.

encodingqrCode.QrCodeGenerateOptions

The qr code encoding options.

idstring

The unique identifier of the machine.

idsPartial<{ root: string; frame: string; }>

The element ids.

modelValuestring

Use this prop to control the value of the qr code via v-model.

EmitEvent
update:modelValue[value: string]

The callback fired when the model value changes.

valueChange[details: ValueChangeDetails]

Callback fired when the value changes.

Context

No serializable props or emits are declared for this part.

DownloadTrigger

PropDefaultType
fileName*string

The name of the file.

mimeType*DataUrlType

The mime type of the image.

asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

qualitynumber

The quality of the image.

Frame

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Overlay

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Pattern

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

RootProvider

PropDefaultType
value*MachineApi<PropTypes>
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Root

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

defaultValuestring

The initial value of the qr code when it is first rendered. Use when you do not need to control the state of the qr code.

encodingqrcode.QrCodeGenerateOptions

The qr code encoding options.

idstring

The unique identifier of the machine.

idsPartial<{ root: string; frame: string; }>

The element ids.

onValueChange(details: qrcode.ValueChangeDetails) => void

Callback fired when the value changes.

valuestring

The value to encode.

Context

PropDefaultType
children*(context: UseQrCodeContext) => ReactNode

DownloadTrigger

PropDefaultType
fileName*string

The name of the file.

mimeType*DataUrlType

The mime type of the image.

asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

qualitynumber

The quality of the image.

Frame

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Overlay

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Pattern

PropDefaultType
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

RootProvider

PropDefaultType
value*UseQrCodeReturn
asChildfalse | true

Use the provided child element as the default rendered element, combining their props and behavior.

Root

PropDefaultType
asChild(props: (userProps?: solid_js369.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

defaultValuestring

The initial value of the qr code when it is first rendered. Use when you do not need to control the state of the qr code.

encodingqrCode.QrCodeGenerateOptions

The qr code encoding options.

idsPartial<{ root: string; frame: string; }>

The element ids.

onValueChange(details: qrCode.ValueChangeDetails) => void

Callback fired when the value changes.

valuestring

The value to encode.

Context

PropDefaultType
children*(context: UseQrCodeContext) => Element

DownloadTrigger

PropDefaultType
fileName*string

The name of the file.

mimeType*DataUrlType

The mime type of the image.

asChild(props: (userProps?: solid_js369.JSX.ButtonHTMLAttributes<HTMLButtonElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

qualitynumber

The quality of the image.

Frame

PropDefaultType
asChild(props: (userProps?: solid_js369.JSX.SvgSVGAttributes<SVGSVGElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Overlay

PropDefaultType
asChild(props: (userProps?: solid_js369.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Pattern

PropDefaultType
asChild(props: (userProps?: solid_js369.JSX.PathSVGAttributes<SVGPathElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

RootProvider

PropDefaultType
value*UseQrCodeReturn
asChild(props: (userProps?: solid_js369.JSX.HTMLAttributes<HTMLDivElement> | undefined) => JSX.HTMLAttributes<any>) => JSX.Element

Use the provided child element as the default rendered element, combining their props and behavior.

Root

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]>
childrenSnippet<[]> | undefined
defaultValuestring
encodingimport("/home/runner/work/ui/ui/packages/svelte/dist/index").QrCodeGenerateOptions

The qr code encoding options.

idstring
idsPartial<{ root: string; frame: string; }>

The element ids.

onValueChange((details: ValueChangeDetails) => void) | undefined

Callback fired when the value changes.

valuestring

The value to encode.

Context

PropDefaultType
apiSnippet<[UseQrCodeContext]>

DownloadTrigger

PropDefaultType
fileName*string

The name of the file.

mimeType*DataUrlType

The mime type of the image.

asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"button">]>
childrenSnippet<[]> | undefined
qualitynumber

The quality of the image.

Frame

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"svg">]>
childrenSnippet<[]> | undefined

Overlay

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"div">]>
childrenSnippet<[]> | undefined

Pattern

PropDefaultType
asChildimport("svelte").Snippet<[import("/home/runner/work/ui/ui/packages/svelte/dist/types").PropsFn<"path">]>
childrenSnippet<[]> | undefined

RootProvider

PropDefaultType
value*UseQrCodeReturn