A simple web app that generates QR codes from user input. Enter any text or URL, click the button, and a QR code appears. Attempting to generate with an empty input triggers a shake animation.
Live Demo β QR Code Generator
- Generates a QR code using a free API
- Supports text or URL input
- Displays the generated QR image
- Shake animation when input is empty
- Clean, minimal UI
/ (root) βββ index.html βββ style.css βββ script.js βββ images/ β βββ delete.png (if used) βββ README.md
- index.html β main HTML markup
- style.css β styling and error animations
- script.js β logic for QR generation, error handling
- images/ β any image assets
- README.md β this project documentation
- Clone or fork the repository
- Open
index.htmlin your browser - Enter a text or URL in the input box
- Click Generate QR
- The QR code image will appear
- If input is empty, the input box shakes (error)
- HTML
- CSS (with keyframe animation for shake effect)
- JavaScript (DOM manipulation, event handling)
- QR Code API:
https://api.qrserver.com/v1/create-qr-code/
- The app takes input from a text field
- If input length > 0:
- Constructs the QR API URL with the input
- Sets the
srcof an<img>to that URL, causing the QR image to load - Displays the image container
- If input is empty:
- Adds
.errorclass to the input element - Uses CSS
@keyframesto animate shake - Removes
.errorafter a short delay so the animation can replay
- Adds
- Make sure input elementβs ID matches in JS (
qrText) - Use
https://in the API URL to avoid mixed content issues - In CSS, include units (e.g.
translateX(-2px)) else transforms may not apply - To replay animation, remove and re-add
.errorclass in JS
Add more features like:
- Downloading the QR image as PNG
- Custom QR size input
- Styling themes (dark mode, etc.)
- Input validation (e.g. only URLs)
Contributions are welcome β fork the repo and submit a pull request!
MIT License β feel free to use and modify the project as you like.