sketch/size

Defines sizes directly with functions, to avoid conversions between int, float and strings.

Types

Size defines a CSS Unit. It can be either px, pt, vh, vw, em, rem, lh, rlh, ch, %. To instanciate a Size, use the corresponding functions. Every unit exposes two functions: the Int function (like px(0)) and the Float version suffixed by an underscore (like px_(0.0)).

pub opaque type Size

Functions

pub fn ch(value: Int) -> Size
pub fn ch_(value: Float) -> Size
pub fn em(value: Float) -> Size
pub fn lh(value: Float) -> Size
pub fn percent(value: Int) -> Size
pub fn percent_(value: Float) -> Size
pub fn pt(value: Int) -> Size
pub fn pt_(value: Float) -> Size
pub fn px(value: Int) -> Size
pub fn px_(value: Float) -> Size
pub fn rem(value: Float) -> Size
pub fn rlh(value: Float) -> Size
pub fn to_string(size: Size) -> String

Internal function, can be used if you need to go from a Size to a String in case you’re building on top of sketch.

pub fn vh(value: Int) -> Size
pub fn vh_(value: Float) -> Size
pub fn vw(value: Int) -> Size
pub fn vw_(value: Float) -> Size
Search Document