React svg qrcode component
Install:
npm install react-qrcode-svg
Import:
;
Use:
const App = <QrCode data="https://github.com/dral/react-qrcode-svg" height="300" width="300" fgColor="#A1B2C3" bgColor="#123456" />;
Options
data
: the data to encodeecLevel
: Error correction level, any ofL
,M
,Q
,H
(default 'L');fgColor
: Foreground color (default:#000
)bgColor
: Background color (default:none
, transparent background)margin
: Margin or quiet zone arround code in number of modules (default4
).- other: Any other properties (
height
,width
, …) will be passed to the underlyingsvg
component.
Gradient fills
Children elements can be used to define more advanced svg attributes such as gradient fills:
const App = <QrCode data="https://github.com/dral/react-qrcode-svg" height="300" width="300" fgColor="url(#gradientFill)" > <linearGradient id="gradientFill" x1="0" y1="0" x2="1" y2=".7"> <stop offset="0%" stopColor="#f857a6"/> <stop offset="100%" stopColor="#ff5858"/> </linearGradient> </QrCode>;
Produces: