shiny (version 0.9.1)

validateCssUnit: Validate proper CSS formatting of a unit

Description

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

Usage

validateCssUnit(x)

Arguments

Value

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

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 followed by a valid suffix: px, %, em, pt, in, cm, mm, ex, or pc.

Any other value will cause an error to be thrown.

Examples

Run this code
validateCssUnit("10%")
validateCssUnit(400)  #treated as '400px'

Run the code above in your browser using DataCamp Workspace