Fetching contributors…
Cannot retrieve contributors at this time
37 lines (32 sloc) 1 KB
\title{Validate proper CSS formatting of a unit}
\item{x}{The unit to validate. Will be treated as a number of pixels if a
unit is not specified.}
A properly formatted CSS unit of length, if possible. Otherwise, will
throw an error.
Checks that the argument is valid for use as a CSS unit of length.
\code{NULL} and \code{NA} are returned unchanged.
Single element numeric vectors are returned as a character vector with the
number plus a suffix of \code{"px"}.
Single element character vectors must be \code{"auto"} or \code{"inherit"},
or a number. If the number has a suffix, it must be valid: \code{px},
\code{\%}, \code{em}, \code{pt}, \code{in}, \code{cm}, \code{mm}, \code{ex},
or \code{pc}. If the number has no suffix, the suffix \code{"px"} is
Any other value will cause an error to be thrown.
validateCssUnit(400) #treated as '400px'