Number variable used with a unit

Published: December 25, 2020

What if we have a custom property that is just a number, but we would like to use it where we need a unit? Then calc is to the rescue.

css
.text {
  --size: 18;
  font-size: calc(var(--size) * 1px);
}