ui.css.as_css_unit

ui.css.as_css_unit(value)

Convert a value into a CSS unit.

Parameters

value: None | CssUnit

A value to convert into a CSS unit.

Returns

Type Description
None | str If the value is None, then None. If the value is 0, then "0". If the value is numeric, then a formatted pixel value. Otherwise, the value as-is.

Examples

from shiny.ui.css import as_css_unit

as_css_unit(0)
'0'
as_css_unit(300)
'300.000000px'
as_css_unit("1em")
'1em'