<div class="app-wrap">
<button id="open-cart-btn" class="main-btn">
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="9" cy="21" r="1"></circle>
<circle cx="20" cy="21" r="1"></circle>
<path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path>
</svg>
Open Cart
</button>
<div class="cart-overlay" id="cart-overlay"></div>
<div class="cart-drawer" id="cart-drawer">
<div class="drawer-header">
<h2>Your Cart</h2>
<button id="close-cart-btn" class="close-btn">
<svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="2">
<line x1="18" y1="6" x2="6" y2="18"></line>
<line x1="6" y1="6" x2="18" y2="18"></line>
</svg>
</button>
</div>
<div class="drawer-body">
<div class="cart-item">
<img src="https://placehold.co/80x80/f3f4f6/a8a29e?text=Shoes" alt="Product">
<div class="item-details">
<h4>Running Shoes</h4>
<p>$89.99</p>
</div>
</div>
<div class="cart-item">
<img src="https://placehold.co/80x80/f3f4f6/a8a29e?text=Shirt" alt="Product">
<div class="item-details">
<h4>Cotton T-Shirt</h4>
<p>$24.99</p>
</div>
</div>
</div>
<div class="drawer-footer">
<div class="subtotal">
<span>Subtotal</span>
<span>$114.98</span>
</div>
<button class="checkout-btn">Proceed to Checkout</button>
</div>
</div>
</div>
Back to Snippets
E-Commerce Cart Drawer JS
Improve your shop with this sliding cart drawer. It slides out smoothly from the right side, and we included a clean layout for products and subtotal.
64