Currency selector pricing in HTML, CSS and vanilla JS
A copy-paste Currency selector pricing in plain HTML and CSS, with vanilla JavaScript: no framework, no build step, MIT-licensed.
Live preview
Source (copy-ready)
<section class="dcl-currency-selector-pricing" data-dcl-scheme="light" aria-labelledby="dcl-currency-selector-pricing-title"><header class="dcl-currency-selector-pricing__header"><h2 id="dcl-currency-selector-pricing-title">Currency selector pricing</h2><p class="dcl-currency-selector-pricing__muted">A labelled currency control updates display-only plan amounts.</p></header><label for="dcl-currency-selector-pricing-currency">Display currency</label><select id="dcl-currency-selector-pricing-currency" data-currency><option value="usd">USD</option><option value="eur">EUR</option><option value="gbp">GBP</option></select><div class="dcl-currency-selector-pricing__grid"><article><h3>Team</h3><p><strong data-price data-base="49">$49</strong> per month</p></article><article><h3>Scale</h3><p><strong data-price data-base="99">$99</strong> per month</p></article></div><p class="dcl-currency-selector-pricing__muted" data-note>Display only; billing occurs in USD for this example.</p><script>(()=>{const root=document.currentScript.closest(".dcl-currency-selector-pricing");if(!root||root.dataset.dclBound)return;root.dataset.dclBound="1";const instance=Array.from(document.getElementsByClassName("dcl-currency-selector-pricing")).indexOf(root);if(instance>0){for(const el of [root,...root.querySelectorAll("*")]){for(const attr of ["id","aria-labelledby","aria-controls","aria-describedby","for","name"]){if(el.hasAttribute(attr))el.setAttribute(attr,el.getAttribute(attr)+"--"+instance)}const href=el.getAttribute("href");if(href&&href.startsWith("#"))el.setAttribute("href",href+"--"+instance)}}const preference=matchMedia("(prefers-color-scheme: dark)"),apply=()=>{root.dataset.dclScheme=preference.matches?"dark":"light"};preference.addEventListener("change",apply);apply();const q=(s)=>root.querySelector(s),qa=(s)=>Array.from(root.querySelectorAll(s));const rates={usd:["$",1],eur:["€",0.92],gbp:["£",0.79]},select=q("[data-currency]");function calc(){const rate=rates[select.value];qa("[data-price]").forEach(p=>p.textContent=rate[0]+Math.round(Number(p.getAttribute("data-base"))*rate[1]))}select.addEventListener("change",calc);calc();})();</script></section>
<style>
.dcl-currency-selector-pricing{color:#11292f;background-color:#ffffff;color-scheme:light;font:1rem/1.45 system-ui,sans-serif;padding:.8rem;border:1px solid #697f84;border-radius:.6rem;overflow-wrap:anywhere}
.dcl-currency-selector-pricing *{box-sizing:border-box}.dcl-currency-selector-pricing h2,.dcl-currency-selector-pricing h3{line-height:1.15;margin-block:0 .6rem}.dcl-currency-selector-pricing a{color:#005c62}
.dcl-currency-selector-pricing button,.dcl-currency-selector-pricing input,.dcl-currency-selector-pricing select,.dcl-currency-selector-pricing textarea,.dcl-currency-selector-pricing summary{min-block-size:44px;border:1px solid #697f84;border-radius:.3rem;padding:.4rem .65rem;font:inherit;color:#11292f;background-color:#e4edef}
.dcl-currency-selector-pricing input,.dcl-currency-selector-pricing select,.dcl-currency-selector-pricing textarea{background-color:#ffffff}.dcl-currency-selector-pricing input[type="radio"],.dcl-currency-selector-pricing input[type="checkbox"]{min-block-size:auto;inline-size:auto}
.dcl-currency-selector-pricing button,.dcl-currency-selector-pricing summary{cursor:pointer}.dcl-currency-selector-pricing button:hover,.dcl-currency-selector-pricing summary:hover{color:#ffffff;background-color:#00535a}
.dcl-currency-selector-pricing button:focus-visible,.dcl-currency-selector-pricing input:focus-visible,.dcl-currency-selector-pricing select:focus-visible,.dcl-currency-selector-pricing textarea:focus-visible,.dcl-currency-selector-pricing summary:focus-visible,.dcl-currency-selector-pricing a:focus-visible{outline:3px solid #005c62;outline-offset:2px}
.dcl-currency-selector-pricing details{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.4rem;margin-block-start:.6rem}.dcl-currency-selector-pricing summary{font-weight:650}
.dcl-currency-selector-pricing dialog{color:#11292f;background-color:#ffffff;border:1px solid #697f84;border-radius:.6rem;max-inline-size:min(34rem,92vw);padding:1rem}
.dcl-currency-selector-pricing table{border-collapse:collapse;inline-size:100%;color:#11292f;background-color:#ffffff}.dcl-currency-selector-pricing th,.dcl-currency-selector-pricing td{padding:.4rem;text-align:start;border-block-end:1px solid #697f84}.dcl-currency-selector-pricing th{color:#11292f;background-color:#e4edef}
.dcl-currency-selector-pricing [hidden]{display:none!important}.dcl-currency-selector-pricing__muted{color:#405a60}.dcl-currency-selector-pricing__panel{color:#405a60;background-color:#ffffff}.dcl-currency-selector-pricing__well{color:#11292f;background-color:#e4edef}.dcl-currency-selector-pricing__primary,.dcl-currency-selector-pricing__badge{color:#ffffff;background-color:#00535a}.dcl-currency-selector-pricing__badge{border-radius:999px;padding:.1rem .45rem;font-size:.8rem;font-weight:700}
.dcl-currency-selector-pricing[data-dcl-scheme="dark"]{color:#eff8f9;background-color:#142f36;color-scheme:dark;border-color:#839fa5}.dcl-currency-selector-pricing[data-dcl-scheme="dark"] a{color:#8fe1da}
.dcl-currency-selector-pricing[data-dcl-scheme="dark"] button,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] input,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] select,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] textarea,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] summary{color:#eff8f9;background-color:#1c3c44;border-color:#839fa5}
.dcl-currency-selector-pricing[data-dcl-scheme="dark"] input,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] select,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] textarea{background-color:#142f36}.dcl-currency-selector-pricing[data-dcl-scheme="dark"] button:hover,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] summary:hover{color:#11292f;background-color:#8fe1da}
.dcl-currency-selector-pricing[data-dcl-scheme="dark"] button:focus-visible,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] input:focus-visible,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] select:focus-visible,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] textarea:focus-visible,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] summary:focus-visible,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] a:focus-visible{outline-color:#8fe1da}
.dcl-currency-selector-pricing[data-dcl-scheme="dark"] details,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] dialog,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] table{color:#eff8f9;background-color:#142f36;border-color:#839fa5}.dcl-currency-selector-pricing[data-dcl-scheme="dark"] th{color:#eff8f9;background-color:#1c3c44}.dcl-currency-selector-pricing[data-dcl-scheme="dark"] th,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] td{border-color:#839fa5}
.dcl-currency-selector-pricing[data-dcl-scheme="dark"] .dcl-currency-selector-pricing__muted{color:#b0c9ce}.dcl-currency-selector-pricing[data-dcl-scheme="dark"] .dcl-currency-selector-pricing__panel{color:#b0c9ce;background-color:#142f36}.dcl-currency-selector-pricing[data-dcl-scheme="dark"] .dcl-currency-selector-pricing__well{color:#eff8f9;background-color:#1c3c44}.dcl-currency-selector-pricing[data-dcl-scheme="dark"] .dcl-currency-selector-pricing__primary,.dcl-currency-selector-pricing[data-dcl-scheme="dark"] .dcl-currency-selector-pricing__badge{color:#11292f;background-color:#8fe1da}
@media (prefers-reduced-motion:reduce){.dcl-currency-selector-pricing *{transition:none!important;animation:none!important}}
.dcl-currency-selector-pricing label{font-weight:700}.dcl-currency-selector-pricing select{display:block;margin-block:.25rem .7rem}.dcl-currency-selector-pricing__grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,10rem),1fr));gap:.75rem}.dcl-currency-selector-pricing__grid article{border-block-start:4px solid #00535a;border-radius:.4rem;padding:.7rem;color:#11292f;background-color:#e4edef}.dcl-currency-selector-pricing[data-dcl-scheme="dark"] .dcl-currency-selector-pricing__grid article{color:#eff8f9;background-color:#1c3c44;border-color:#8fe1da}</style>
When to use
Use only for approximate display conversion when billing currency rules are explicit. Keep exchange-rate provenance outside the component.
Avoid
Do not silently switch billing currency or imply checkout conversion without confirming tax and payment-provider behavior.
Accessibility
Currency selection uses a labelled native select and all displayed totals are text; the billing caveat remains adjacent. Prices and controls are plain text with visible focus. Light text is #11292f/#405a60 on #ffffff (15.19:1/7.37:1); dark text is #eff8f9/#b0c9ce on #142f36 (13.07:1/8.12:1).
Was this useful? Send feedback.