WHATSAPP LAUNCHER
Start chats faster. Get replies quicker.
Make it easy for visitors to message you on WhatsApp — instantly. Mobile users jump straight into chat with a pre-filled message. Desktop users scan a QR code incase they don't have WhatsApp on their computer or click to open WhatsApp Web if they have it set up. Reducing friction, speeding up conversations. We highly recommend you put this into your AI platform of choice and further customise it.

Documentation
Tool
We've listed the code documentation below.
WhatsApp Button Widget Overview
The WhatsApp Button Widget creates a professional, responsive button that seamlessly connects website visitors with businesses via WhatsApp. It features smart device detection to show a QR code modal on desktop while opening WhatsApp directly on mobile devices, with customizable styling and pre-filled messages for improved user engagement.
HTML Structure
The generated HTML structure consists of:
- A unique wrapper ID like whatsapp-button-abc123 for complete isolation
- Scoped CSS styles prefixed with the wrapper ID to prevent conflicts
- A button element with data-whatsapp-modal-trigger attribute
- Inline SVG WhatsApp icon with currentColor fill for dynamic coloring
- Optional modal container with data-whatsapp-modal-status for state management
- Self-contained JavaScript wrapped in an IIFE (Immediately Invoked Function Expression)
Button Implementation
The button component includes several key features:
- Transparent background with colored border using border: 2px solid
- CSS transitions on all properties: transition: all 0.3s ease
- Flexbox layout for icon and text alignment: display: inline-flex
- Responsive padding that adjusts based on selected size (small/medium/large)
- Icon sizing synchronized with button size using CSS custom properties
- Hover state with background fill and text color inversion
Modal Functionality
The optional QR code modal provides desktop-friendly access:
- Fixed positioning with position: fixed; inset: 0 for full viewport coverage
- Z-index of 100000 ensures visibility above other elements
- State management via data-whatsapp-modal-status attribute
- Cubic bezier transitions: cubic-bezier(0.625, 0.05, 0, 1)
- Dark overlay with background-color: #0003 for focus
- Transform animations: translateY(25%) to translateY(0%)
QR Code Generation
Dynamic QR codes are generated using a public API:
- API endpoint: https://api.qrserver.com/v1/create-qr-code/
- QR size parameter: size=540x540 for high resolution
- WhatsApp URL format: https://wa.me/{number}?text={message}
- URL encoding with encodeURIComponent() for special characters
- Image element dynamically created and inserted into [data-whatsapp-modal-qr-canvas]
- Fallback background color removed when image loads successfully
Device Detection
Smart device detection ensures optimal user experience:
- Mobile detection: window.matchMedia('(hover: none) and (pointer: coarse)')
- Combines hover capability and pointer precision checks
- Mobile devices bypass modal and use window.open() directly
- Desktop devices trigger modal with setAttribute('data-whatsapp-modal-status', 'active')
- Responsive CSS hides button text at max-width: 1400px
- Icon-only mode maintains button functionality on smaller screens
Event Handling
The widget implements comprehensive event management:
- Click handler on button with preventDefault() and stopPropagation()
- Modal toggle via [data-whatsapp-modal-toggle] elements
- Escape key listener: event.key === 'Escape' || event.keyCode === 27
- Dark overlay click closes modal for intuitive UX
- Close button with rotating animation on hover
- All event listeners properly scoped to widget instance
Styling Architecture
The CSS implementation follows best practices:
- All selectors prefixed with unique ID to prevent cascade issues
- Box-sizing reset: box-sizing: border-box on all elements
- Font family inheritance with fallback: font-family: 'Inter', sans-serif
- Relative units for responsive scaling
- CSS custom properties could extend customization (future enhancement)
- Media queries for responsive breakpoints at 768px and 1400px
URL Structure
WhatsApp URLs follow a specific format for compatibility:
- Base URL: https://wa.me/ for universal support
- Phone number format: Country code + number without symbols (e.g., 447457414356 )
- Message parameter: ?text= followed by encoded text
- Special characters handled with encodeURIComponent()
- String escaping in generated code uses replace(/'/g, "\\'")
- Same URL works for both QR codes and direct links
Responsive Behavior
The widget adapts seamlessly across devices:
- Desktop: Full button with text and optional modal
- Tablet/Mobile: Icon-only mode triggered at 1400px breakpoint
- Modal responsive at 768px with reduced padding
- Width constraints: width: 90%; max-width: 20em on mobile
- Touch-friendly tap targets maintained in all sizes
- Z-index management ensures proper stacking on complex layouts
Animation Details
Smooth animations enhance the user experience:
- Button hover: background-color and color transitions
- Modal entrance: opacity: 0 to 1 with transform
- Close button rotation: transform: rotate(90deg) on hover
- Visibility toggle prevents interaction during transitions
- Hardware acceleration with rotate(0.001deg) hack
- Pointer-events management for proper click handling
Accessibility Considerations
The widget includes several accessibility features:
- Semantic button element maintains keyboard navigation
- SVG includes proper viewBox for scalability
- Color contrast maintained in all states
- Focus styles preserved with outline: none removed on customization
- Alt text on QR code image: alt="WhatsApp QR Code"
- Modal escape key support for keyboard users
Performance Optimization
The implementation prioritizes performance:
- Single external request for QR code generation
- No JavaScript libraries or dependencies
- Event delegation where applicable
- CSS animations use GPU-accelerated properties
- Lazy QR code generation only when modal opens
- Minimal DOM manipulation after initialization
- Efficient selector caching in closure scope
Implementation Benefits
This solution offers significant advantages over alternatives:
- Zero dependencies - no jQuery, React, or other frameworks needed
- Self-contained code prevents version conflicts
- Works immediately without initialization delays
- Compatible with all modern browsers including Safari 12+
- No CORS issues with QR code generation
- SEO-friendly with proper semantic markup
- GDPR compliant - no tracking or cookies
- Lightweight footprint under 10KB total
- Works with CSP (Content Security Policy) restrictions
- Can be dynamically inserted via JavaScript
Create Your WhatsApp Button
Enter number with country code, without + or spaces
This message will appear in the WhatsApp chat when users click your button
Text shown next to the WhatsApp icon (hidden on mobile)
Button Appearance
Type "transparent" for no background
Corner roundness in pixels
Font for all text in the widget
Modal Settings
Desktop users see a modal with QR code, mobile users open WhatsApp directly
Title shown in the modal popup
Corner roundness of the modal in pixels
Semantic heading level for accessibility
Get Your Code
Copy and paste this code into your website to add the WhatsApp button:
- Copy the code above
- Paste it into your website HTML where you want the button to appear
- The button will work immediately - no configuration needed
Features of this WhatsApp button:
✓ Responsive design - shows icon only on mobile
✓ Pre-filled message for quick communication
✓ Optional QR code modal for desktop users
✓ Customizable colors and styling
✓ Works on all devices and browsers
✓ No external dependencies
Why This Isn't Available as a Duda Widget
The reason that these tools are not available as Duda widgets is simply because Duda limits the shareable widget link to 24 hours for one user.
This frankly makes it unrealistic to share with all users. Our dream and shared vision with multiple other Duda experts is that Duda unlock this share link so that those who can build widgets can give them away much easier by just having to generate one link that can be used multiple times by multiple users to add to as many Duda instances as possible.

Please contribute by upvoting the Duda idea to increase the limits on the link!
Upvote the IdeaWorking Preview:
The live preview in the tool shows the colours rather than actually works. Click below to see the resulting codes outcome:
Resource Details:
WhatsApp Button transforms casual website visitors into instant conversations by providing a seamless, one-click connection to your business messaging. Instead of forcing users through lengthy contact forms or email delays, this smart widget detects their device and delivers the perfect experience – a scannable QR code modal for desktop users or direct app integration on mobile. The pre-filled message feature eliminates friction by starting conversations with context, while the responsive design ensures the button looks professional whether it's showing full text on desktop or adapting to a sleek icon-only mode on smaller screens. Includes customizable colors to match your brand, optional modal popup for desktop users, flexible sizing options, and generates lightweight, dependency-free code that works instantly on any website.
Last Updated:
July 8th 2025
Category:
Call To Action
