Back to all widgets
Source Code
Content & LayoutDisplay formatted code blocks with syntax highlighting
Key Features
7 languages
Dark/light themes
Line numbers
Copy-friendly
Design Variations
Design 1: Dark Theme with Line Numbers
javascript
1// Add to cart functionality2async function addToCart(productId, quantity) {3 const response = await fetch('/api/cart', {4 method: 'POST',5 headers: { 'Content-Type': 'application/json' },6 body: JSON.stringify({ productId, quantity }),7 });8 const data = await response.json();9 updateCartBadge(data.totalItems);10 showToast('Added to cart!');11}Design 2: Light Theme
html
<div class="product-card">
<img src="/images/product.jpg" alt="Handcrafted Vase" />
<h3>Handcrafted Ceramic Vase</h3>
<p class="price">₹1,299</p>
<button class="add-to-cart">Add to Cart</button>
</div>Start Building with Source Code
Get access to this widget and 108 more with StoreBase's visual page builder.