Skip to content

CSS Showcase · Live Demo

Math, but make it markup.

The output element ties a result to its inputs with for= — live invoice totals, unit conversion, and a tip calculator. JavaScript computes; output displays.

Featured demo

mobile · tip
Total$56.88

mobile design patterns

output-tip.css
/* Tip calculator */
.tip-card {
  display: grid;
  gap: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 1.1rem;
  background: var(--card);
  padding: 1rem;
}

.tip-card label { font-size: 0.72rem; font-weight: 600; color: var(--muted-foreground); }

.tip-card input {
  block-size: 2.75rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: var(--background);
  padding: 0 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.tip-card .tip-scale {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.tip-card .tip-scale button {
  block-size: 2.4rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--card);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.tip-card .tip-scale button[aria-pressed="true"] {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.tip-card .tip-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-block-start: 1px solid var(--border);
  padding-block-start: 0.7rem;
}

.tip-card .tip-total span { font-size: 0.78rem; font-weight: 600; }

.tip-card .tip-total output {
  font-size: 1.45rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  animation: result-pop 0.25s ease;
}

@keyframes result-pop {
  from { scale: 1.06; opacity: 0.4; }
  to { scale: 1; opacity: 1; }
}

CSS features used

  • • output for="…"
  • • font-variant-numeric: tabular-nums
  • • keyframe pop on change
  • • aria-live results
  • • accent-color sliders
  • • Semantic tokens

CSS Showcase · Share

Share this demo as a 1:1 image

A 2048×2048 PNG with the live current view, the title, and the CSS features — for social posts, docs, and READMEs.

The snapshot follows the device selected on the page — switch between desktop, iPad, and mobile above and the card updates.