MorphCanvas
HomeGallery › Tip Calculator

Tip Calculator

A compact tip calculator with bill input and preset percentage buttons on a dark theme.

★ 0 community votes · Safety scan passed · Sandboxed preview

About this component

Tip Calculator is an interface component generated on MorphCanvas, an infinite AI workspace that turns written intent into reviewable HTML, CSS, and JavaScript widgets. This component passed MorphCanvas’s automated safety scan, which checks for unsafe patterns such as external network calls, storage access, inline event handlers, and code execution, and it is rendered here inside a sandboxed preview frame.

How it was built

A creator described the result they wanted, MorphCanvas routed the request through its AI provider chain with automatic failover, scanned the generated code, and published the reviewed component to the public library. You can build and publish your own components on the MorphCanvas canvas.

Source

HTML

<div class="tip-calc"><input type="number" id="bill" placeholder="Bill amount" min="0" step="0.01"><div class="buttons"><button data-perc="10">10%</button><button data-perc="15">15%</button><button data-perc="20">20%</button></div><div id="result">Tip: $0.00</div></div>

CSS

body{background:#222;color:#fff;font-family:sans-serif;margin:0;padding:20px}.tip-calc{max-width:300px;margin:auto}.tip-calc input{width:100%;padding:10px;margin-bottom:10px;border:none;border-radius:4px}.buttons{display:flex;gap:5px;margin-bottom:10px}.buttons button{flex:1;padding:10px;border:none;border-radius:4px;background:#444;color:#fff;cursor:pointer}.buttons button:hover{background:#555}.buttons button:focus{outline:none}.buttons button:active{background:#666}#result{font-size:1.2em}

JavaScript

const billInput=document.getElementById('bill');const result=document.getElementById('result');const buttons=document.querySelectorAll('.buttons button');function updateTip(perc){const bill=parseFloat(billInput.value)||0;const tip=(bill*perc/100).toFixed(2);result.textContent=`Tip: $${tip}`;}buttons.forEach(btn=>btn.addEventListener('click',()=>updateTip(parseFloat(btn.dataset.perc))));billInput.addEventListener('input',()=>{const perc=parseFloat(buttons[1].dataset.perc)||15;updateTip(perc)});
Build your own on MorphCanvas