validateCssUnit

0th

Percentile

Validate proper CSS formatting of a unit

Checks that the argument is valid for use as a CSS unit of length.

Usage
validateCssUnit(x)
Arguments
x

The unit to validate. Will be treated as a number of pixels if a unit is not specified.

Details

NULL and NA are returned unchanged.

Single element numeric vectors are returned as a character vector with the number plus a suffix of "px".

Single element character vectors must be "auto" or "inherit", or a number. If the number has a suffix, it must be valid: px, %, em, pt, in, cm, mm, ex, or pc. If the number has no suffix, the suffix "px" is appended.

Any other value will cause an error to be thrown.

Value

A properly formatted CSS unit of length, if possible. Otherwise, will throw an error.

Aliases
  • validateCssUnit
Examples
# NOT RUN {
validateCssUnit("10%")
validateCssUnit(400)  #treated as '400px'
# }
Documentation reproduced from package shiny, version 1.1.0, License: GPL-3 | file LICENSE

Community examples

Looks like there are no examples yet.