UNPKG

react-qrcode

Version:

🤳 A React component for QR code generation with `qrcode`

73 lines (53 loc) • 5.18 kB
# ReactQRCode > 🤳 A React component for QR code generation with [qrcode](https://github.com/soldair/node-qrcode) ## Demo <ReactQrcodeDemo /> ## Usage ```tsx // Component import ReactDOM from 'react-dom' import { QRCode } from 'react-qrcode' ReactDOM.render(<QRCode value="https://www.1stg.me" />) // hooks import { useQRCode } from 'react-qrcode' export const App = () => { const [value, setValue] = useState('https://www.1stg.me') const dataUrl = useQRCode(value) return ( <> <div>dataUrl: {dataUrl}</div> <img src={dataUrl} /> <input onChange={e => setValue(e.currentTarget.value)} /> </> ) } ``` ## Available Props | prop | type (range) | default value | | ---------------------- | ------------------------------------------------------------------ | ------------------------------------------- | | `version` | `number` (1-40) | N/A | | `errorCorrectionLevel` | `String` ('low', 'medium', 'quartile', 'high', 'L', 'M', 'Q', 'H') | `'M'` | | `maskPattern` | `number` (0-7) | N/A | | `toSJISFunc` | `Function` | N/A | | `margin` | `number` | `4` | | `scale` | `number` | `4` | | `width` | `number` | N/A | | `color` | `{ dark: string; light:string }` | `{ dark: '#000000ff', light: '#ffffffff' }` | | `type` | `string` ('image/png', 'image/jpeg', 'image/webp') | `'image/png'` | | `quality` | `number`(0-1) | `0.92` | | `value` | `string \| Array<{ data: string; mode?: string }>` | N/A | ## Sponsors | 1stG | RxTS | UnTS | | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | [![1stG Open Collective backers and sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers and sponsors](https://opencollective.com/rxts/organizations.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers and sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) | ## Backers | 1stG | RxTS | UnTS | | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | | [![1stG Open Collective backers and sponsors](https://opencollective.com/1stG/individuals.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers and sponsors](https://opencollective.com/rxts/individuals.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers and sponsors](https://opencollective.com/unts/individuals.svg)](https://opencollective.com/unts) | ## Changelog Detailed changes for each release are documented in [CHANGELOG.md](./CHANGELOG.md). ## License [MIT][] © [JounQin][]@[1stG.me][] [1stg.me]: https://www.1stg.me [jounqin]: https://GitHub.com/JounQin [mit]: http://opensource.org/licenses/MIT