I like the tricks :) – Kasia
Limit the possible values to the ones that make sense.
type CssProperty =
"margin-top" | "margin-right" | "margin-bottom" | "margin-left" |
"padding-top" | "padding-right" | "padding-bottom" | "padding-left"
// Or if you are as lazy as I am
type Prefix = "margin" | "padding"
type Suffix = "top" | "right" | "bottom" | "left"
type CssProperty =
`${Prefix}-${Suffix}` // ✅ Same as the above `CssProperty`
`${Prefix}${"" | `-${Suffix}`}` // ✅ Includes "margin" and "padding"
Crafted with 💛 by Riccardo
Crafted with 💛 by Riccardo