Beginner Mini-Project • HTML • CSS Grid • Vanilla JS
⏱ Est. Build Time: 25 minsWeekend Build · Single-File App
🍔 Interactive Fast-Food Menu
Build a responsive restaurant ordering interface with category tabs, live keyword search, dynamic CSS Grid cards, a persistent order tray with 8% tax calculation, and toast notifications.
Last updated: November 2026 · 7 min read
Modern ordering interfaces keep the menu and order summary visible side-by-side without page reloads. You store menu items as a JavaScript array, render filtered cards dynamically into a CSS Grid, and manage cart quantities with Array.reduce() and localStorage.
What you will build: A two-column ordering app featuring 4 category filters (All, Burgers, Sides, Drinks, Combos), live search, quantity steppers (+ / -), automatic subtotal/tax math, persistent cart storage, and instant toast confirmations.
🎬 Live Working Demo
Test the standalone ordering app in a dedicated full-screen tab before inspecting the code.
MAK Grill — Interactive Ordering UI
Filter burgers, sides, and combos, adjust item quantities in the sticky order tray, reload the page to verify localStorage persistence, and place a test order.
📦 Complete Single-File Source Code
Save this as fast-food-menu.html and open it in any browser — no build tools or server required.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>MAK Grill — Interactive Fast-Food Menu</title>
<style>
:root {
--bg: #0f172a;
--surface: #1e293b;
--surface-hover: #273549;
--border: #334155;
--accent: #f97316;
--accent-hover: #ea580c;
--text: #f8fafc;
--muted: #94a3b8;
--success: #22c55e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
padding: 1.5rem;
}
.app-container {
max-width: 1180px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr 360px;
gap: 1.75rem;
align-items: start;
}
header {
max-width: 1180px;
margin: 0 auto 1.5rem;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
gap: 1rem;
padding-bottom: 1rem;
border-bottom: 1px solid var(--border);
}
.brand h1 { font-size: 1.5rem; font-weight: 800; }
.brand p { font-size: 0.85rem; color: var(--muted); }
.search-box input {
background: var(--surface);
border: 1px solid var(--border);
color: var(--text);
padding: 0.65rem 1rem;
border-radius: 8px;
width: 260px;
font-size: 0.9rem;
outline: none;
}
.search-box input:focus { border-color: var(--accent); }
/* Category Tabs */
.tabs {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
margin-bottom: 1.25rem;
}
.tab-btn {
background: var(--surface);
color: var(--muted);
border: 1px solid var(--border);
padding: 0.5rem 1rem;
border-radius: 999px;
cursor: pointer;
font-weight: 600;
font-size: 0.85rem;
transition: 0.2s;
}
.tab-btn:hover { color: var(--text); border-color: var(--accent); }
.tab-btn.active {
background: var(--accent);
color: #fff;
border-color: var(--accent);
}
/* Menu Grid */
.menu-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
gap: 1rem;
}
.food-card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 1.15rem;
display: flex;
flex-direction: column;
justify-content: space-between;
transition: transform 0.2s, border-color 0.2s;
}
.food-card:hover {
transform: translateY(-3px);
border-color: var(--accent);
}
.food-emoji { font-size: 2.4rem; margin-bottom: 0.6rem; }
.food-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.3rem; }
.food-desc { font-size: 0.82rem; color: var(--muted); line-height: 1.4; margin-bottom: 1rem; }
.food-footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: auto;
}
.price { font-size: 1.1rem; font-weight: 800; color: #fb923c; }
.add-btn {
background: var(--accent);
color: #fff;
border: none;
padding: 0.45rem 0.9rem;
border-radius: 8px;
font-weight: 700;
font-size: 0.82rem;
cursor: pointer;
transition: 0.2s;
}
.add-btn:hover { background: var(--accent-hover); }
/* Sticky Order Tray */
.cart-panel {
background: var(--surface);
border: 1px solid var(--border);
border-radius: 14px;
padding: 1.25rem;
position: sticky;
top: 1.5rem;
}
.cart-header {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 0.85rem;
border-bottom: 1px solid var(--border);
margin-bottom: 1rem;
}
.clear-btn {
background: transparent;
border: none;
color: #f87171;
font-size: 0.8rem;
cursor: pointer;
font-weight: 600;
}
.cart-items {
display: flex;
flex-direction: column;
gap: 0.75rem;
max-height: 320px;
overflow-y: auto;
margin-bottom: 1rem;
}
.cart-item {
display: flex;
justify-content: space-between;
align-items: center;
background: var(--bg);
padding: 0.65rem 0.85rem;
border-radius: 8px;
font-size: 0.88rem;
}
.qty-controls {
display: flex;
align-items: center;
gap: 0.45rem;
}
.qty-btn {
background: var(--surface);
border: 1px solid var(--border);
color: var(--text);
width: 24px;
height: 24px;
border-radius: 6px;
cursor: pointer;
font-weight: 700;
}
.summary-row {
display: flex;
justify-content: space-between;
font-size: 0.88rem;
color: var(--muted);
margin-bottom: 0.4rem;
}
.summary-total {
display: flex;
justify-content: space-between;
font-size: 1.1rem;
font-weight: 800;
color: var(--text);
border-top: 1px solid var(--border);
padding-top: 0.75rem;
margin-top: 0.5rem;
}
.checkout-btn {
width: 100%;
margin-top: 1rem;
background: var(--success);
color: #052e16;
border: none;
padding: 0.8rem;
border-radius: 10px;
font-weight: 800;
font-size: 0.95rem;
cursor: pointer;
}
.checkout-btn:disabled {
opacity: 0.45;
cursor: not-allowed;
}
/* Toast Notification */
#toast {
position: fixed;
bottom: 1.5rem;
right: 1.5rem;
background: #0f172a;
color: #f8fafc;
border: 1px solid var(--accent);
border-left: 4px solid var(--accent);
padding: 0.85rem 1.2rem;
border-radius: 10px;
font-size: 0.88rem;
font-weight: 600;
box-shadow: 0 12px 30px rgba(0,0,0,0.45);
opacity: 0;
transform: translateY(16px);
pointer-events: none;
transition: opacity 0.25s ease, transform 0.25s ease;
z-index: 99999;
}
#toast.show {
opacity: 1;
transform: translateY(0);
}
@media (max-width: 860px) {
.app-container { grid-template-columns: 1fr; }
.cart-panel { position: static; }
}
</style>
</head>
<body>
<header>
<div class="brand">
<h1>🍔 MAK Grill</h1>
<p>Freshly coded & served fast</p>
</div>
<div class="search-box">
<input type="text" id="searchInput" placeholder="Search burgers, fries, drinks..." />
</div>
</header>
<div class="app-container">
<main>
<div class="tabs" id="categoryTabs">
<button class="tab-btn active" data-cat="all">All Items</button>
<button class="tab-btn" data-cat="burgers">Burgers</button>
<button class="tab-btn" data-cat="sides">Sides</button>
<button class="tab-btn" data-cat="drinks">Drinks</button>
<button class="tab-btn" data-cat="combos">Combos</button>
</div>
<div class="menu-grid" id="menuGrid"></div>
</main>
<aside class="cart-panel">
<div class="cart-header">
<h2>Your Order (<span id="cartCount">0</span>)</h2>
<button class="clear-btn" id="clearCartBtn">Clear</button>
</div>
<div class="cart-items" id="cartItems"></div>
<div class="summary-row"><span>Subtotal</span><span id="subtotalEl">$0.00</span></div>
<div class="summary-row"><span>Tax (8%)</span><span id="taxEl">$0.00</span></div>
<div class="summary-total"><span>Total</span><span id="totalEl">$0.00</span></div>
<button class="checkout-btn" id="checkoutBtn" disabled>Place Order</button>
</aside>
</div>
<div id="toast" role="status" aria-live="polite"></div>
<script>
const MENU = [
{ id: 1, name: "Double Smash Burger", cat: "burgers", price: 8.99, emoji: "🍔", desc: "Two crispy-edged beef patties, aged cheddar, house sauce." },
{ id: 2, name: "Crispy Zinger Fillet", cat: "burgers", price: 7.49, emoji: "🍗", desc: "Spicy buttermilk chicken breast, iceberg lettuce, garlic mayo." },
{ id: 3, name: "Smoky BBQ Melt", cat: "burgers", price: 9.49, emoji: "🥓", desc: "Caramelized onions, smoked beef strips, hickory BBQ glaze." },
{ id: 4, name: "Loaded Cheese Fries", cat: "sides", price: 4.29, emoji: "🍟", desc: "Golden skin-on fries topped with warm jalapeno cheese sauce." },
{ id: 5, name: "Crispy Onion Rings", cat: "sides", price: 3.99, emoji: "🧅", desc: "Thick-cut sweet onions in a crunchy seasoned batter." },
{ id: 6, name: "Iced Mint Lemonade", cat: "drinks", price: 2.99, emoji: "🥤", desc: "Freshly squeezed lemons blended with crushed garden mint." },
{ id: 7, name: "Chocolate Shake", cat: "drinks", price: 4.49, emoji: "🍫", desc: "Rich Belgian cocoa ice cream spun thick with whipped cream." },
{ id: 8, name: "MAK Mega Box", cat: "combos", price: 13.99, emoji: "🍱", desc: "Double Smash Burger, regular fries, 4 nuggets & chilled drink." }
];
let activeCat = "all";
let searchQuery = "";
let cart = [];
try {
cart = JSON.parse(localStorage.getItem("mak_food_cart")) || [];
} catch (e) {
cart = [];
}
const menuGrid = document.getElementById("menuGrid");
const cartItemsEl = document.getElementById("cartItems");
const toastEl = document.getElementById("toast");
let toastTimer;
function showToast(msg) {
clearTimeout(toastTimer);
toastEl.textContent = msg;
toastEl.classList.remove("show");
void toastEl.offsetWidth; // Force reflow so animation replays cleanly
toastEl.classList.add("show");
toastTimer = setTimeout(() => toastEl.classList.remove("show"), 2600);
}
function renderMenu() {
const filtered = MENU.filter(item => {
const matchCat = activeCat === "all" || item.cat === activeCat;
const matchSearch = item.name.toLowerCase().includes(searchQuery) ||
item.desc.toLowerCase().includes(searchQuery);
return matchCat && matchSearch;
});
if (!filtered.length) {
menuGrid.innerHTML = `<p style="color:#94a3b8;grid-column:1/-1;">No menu items match your filter.</p>`;
return;
}
menuGrid.innerHTML = filtered.map(item => `
<article class="food-card">
<div>
<div class="food-emoji">${item.emoji}</div>
<h3 class="food-title">${item.name}</h3>
<p class="food-desc">${item.desc}</p>
</div>
<div class="food-footer">
<span class="price">$${item.price.toFixed(2)}</span>
<button class="add-btn" onclick="addToCart(${item.id})">+ Add</button>
</div>
</article>
`).join("");
}
function saveAndRenderCart() {
localStorage.setItem("mak_food_cart", JSON.stringify(cart));
const totalQty = cart.reduce((sum, item) => sum + item.qty, 0);
const subtotal = cart.reduce((sum, item) => sum + item.price * item.qty, 0);
const tax = subtotal * 0.08;
const total = subtotal + tax;
document.getElementById("cartCount").textContent = totalQty;
document.getElementById("subtotalEl").textContent = `$${subtotal.toFixed(2)}`;
document.getElementById("taxEl").textContent = `$${tax.toFixed(2)}`;
document.getElementById("totalEl").textContent = `$${total.toFixed(2)}`;
document.getElementById("checkoutBtn").disabled = cart.length === 0;
if (!cart.length) {
cartItemsEl.innerHTML = `<p style="color:#94a3b8;font-size:0.85rem;text-align:center;padding:1.5rem 0;">Your tray is empty.</p>`;
return;
}
cartItemsEl.innerHTML = cart.map(item => `
<div class="cart-item">
<div>
<div style="font-weight:700;">${item.emoji} ${item.name}</div>
<div style="color:#94a3b8;font-size:0.78rem;">$${(item.price * item.qty).toFixed(2)}</div>
</div>
<div class="qty-controls">
<button class="qty-btn" onclick="updateQty(${item.id}, -1)">-</button>
<span>${item.qty}</span>
<button class="qty-btn" onclick="updateQty(${item.id}, 1)">+</button>
</div>
</div>
`).join("");
}
window.addToCart = function(id) {
const product = MENU.find(m => m.id === id);
const existing = cart.find(c => c.id === id);
if (existing) {
existing.qty += 1;
} else {
cart.push({ ...product, qty: 1 });
}
saveAndRenderCart();
showToast(`Added ${product.name} to order`);
};
window.updateQty = function(id, delta) {
const index = cart.findIndex(c => c.id === id);
if (index === -1) return;
cart[index].qty += delta;
if (cart[index].qty <= 0) {
const removed = cart.splice(index, 1)[0];
showToast(`Removed ${removed.name}`);
}
saveAndRenderCart();
};
document.getElementById("categoryTabs").addEventListener("click", e => {
if (!e.target.classList.contains("tab-btn")) return;
document.querySelectorAll(".tab-btn").forEach(b => b.classList.remove("active"));
e.target.classList.add("active");
activeCat = e.target.dataset.cat;
renderMenu();
});
document.getElementById("searchInput").addEventListener("input", e => {
searchQuery = e.target.value.trim().toLowerCase();
renderMenu();
});
document.getElementById("clearCartBtn").addEventListener("click", () => {
if (!cart.length) return;
cart = [];
saveAndRenderCart();
showToast("Order tray cleared");
});
document.getElementById("checkoutBtn").addEventListener("click", () => {
const total = document.getElementById("totalEl").textContent;
cart = [];
saveAndRenderCart();
showToast(`Order placed! Total charged: ${total}`);
});
renderMenu();
saveAndRenderCart();
</script>
</body>
</html>
🧱 How it works (6-step breakdown)
The outer .app-container uses grid-template-columns: 1fr 360px. The left column fluidly adapts to screen width, while the right-hand order tray stays pinned at 360px with position: sticky; top: 1.5rem. Below 860px, a media query collapses it into a single stacked column for mobile screens.
Instead of hardcoding 8 separate HTML cards, every dish lives as a plain object inside const MENU. Calling renderMenu() maps matching objects into semantic <article class="food-card"> blocks, making it effortless to add new items or connect a JSON API later.
Two lightweight state variables — activeCat and searchQuery — work together inside MENU.filter(). An item only renders if it satisfies both conditions, so typing "spicy" while on the "Burgers" tab narrows results accurately.
Every cart update runs through saveAndRenderCart(). Two .reduce() passes compute total item count and dollar subtotal in one clean loop, then derive 8% sales tax and the final total formatted with .toFixed(2).
The cart array is serialized via JSON.stringify(cart) on every change. On startup, JSON.parse() is wrapped inside a try/catch block so private-browsing restrictions or malformed storage never crash the script.
Rapidly clicking "+ Add" can skip CSS transitions if a class is removed and re-added in the same paint frame. Reading void toastEl.offsetWidth forces the browser to flush layout styles before re-applying .show, ensuring smooth replay every time.
🚀 Weekend extension challenges
Once the base menu works, level up your build with these three practical upgrades:
Add a coupon input above the subtotal that recognizes MAK10 for a 10% discount before tax is calculated.
Add a tags: ["spicy", "popular"] array to each menu object and render small colored pills on the food cards.
When clicking "Place Order", display an itemized order receipt modal with a generated order number (e.g., #MAK-4082) before clearing the cart.
⚠️ Common mistakes to avoid
- Mutating original MENU objects directly. Always spread
{ ...product, qty: 1 }when pushing tocartso menu data stays clean. - Forgetting
.toFixed(2)on currency math. JavaScript floating-point math produces values like13.489999999999998without formatting. - Leaving zero-quantity items in the cart array. Remove items cleanly with
cart.splice(index, 1)onceqtyhits0. - Low toast
z-index. Keep#toastabove sticky headers and sidebars so mobile users always see confirmation messages.
❓ Frequently asked questions
How do I filter menu items by both category and search text?
Keep two state variables (activeCategory and searchQuery) and filter your menu array using Array.prototype.filter() so an item must match both the selected category and the search string before rendering.
How do I calculate cart totals accurately in JavaScript?
Use Array.prototype.reduce() over your cart array to sum item.price * item.qty, compute tax from that subtotal, and format all currency displays with .toFixed(2) to avoid floating-point display glitches.
Why does my CSS toast animation fail to replay on repeated clicks?
Browsers batch class removals and additions within the same frame. Triggering a forced reflow with void toast.offsetWidth between removing and re-adding the active class restarts the CSS transition cleanly.
How do I persist the customer's cart across page reloads?
Serialize the cart array with JSON.stringify(cart) and store it via localStorage.setItem('mak_food_cart', ...). On page load, read and parse it inside a try/catch block so corrupted storage never breaks the app.