v150 · CSS · e-commerce

Price Tag

Product prices vary enormously in length — from $1 to $1,299.99 to ¥12,800. With text-fit: shrink, every price bubble uses the same fixed dimensions while long values scale down automatically. Toggle the mode off to see the overflow problem.

text-fit: shrink active — long prices fit their bubble
/* Fixed-size price bubble — text scales to fit automatically */
.price-bubble {
  width: 100%;
  height: 52px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.price-text {
  font-size: 2rem;           /* initial / upper bound */
  text-fit: shrink;
  white-space: nowrap;
  display: block;
  width: 100%;
  text-align: center;
}

/* Without text-fit, long prices clip or overflow */

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗