Module Css_gen

A set of functions to generate css declaration lists. This library can be used to programmatically produce strings suitable for the HTML style attribute, e.g. style="display:flex;background-color:red".

type css_global_values = [
| `Inherit
| `Initial
]
val sexp_of_css_global_values : css_global_values -> Ppx_sexp_conv_lib.Sexp.t
val css_global_values_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> css_global_values
val __css_global_values_of_sexp__ : Ppx_sexp_conv_lib.Sexp.t -> css_global_values
val compare_css_global_values : css_global_values -> css_global_values -> int
module Color : sig ... end
module Length : sig ... end
module Auto_or_length : sig ... end
type t
include Ppx_sexp_conv_lib.Sexpable.S with type t := t
type t
val t_of_sexp : Sexplib0.Sexp.t -> t
val sexp_of_t : t -> Sexplib0.Sexp.t
val compare : t -> t -> int
include Bin_prot.Binable.S with type t := t
type t
include Bin_prot.Binable.S_only_functions with type t := t
type t
val bin_size_t : t Bin_prot.Size.sizer
val bin_write_t : t Bin_prot.Write.writer
val bin_read_t : t Bin_prot.Read.reader
val __bin_read_t__ : (int -> t) Bin_prot.Read.reader

This function only needs implementation if t exposed to be a polymorphic variant. Despite what the type reads, this does *not* produce a function after reading; instead it takes the constructor tag (int) before reading and reads the rest of the variant t afterwards.

val bin_shape_t : Bin_prot.Shape.t
val bin_writer_t : t Bin_prot.Type_class.writer
val bin_reader_t : t Bin_prot.Type_class.reader
val bin_t : t Bin_prot.Type_class.t
val create : field:string -> value:string -> t

Create a single property, value pair (a declaration in CSS parlance). The value must be a valid CSS literal. We do run a simple CSS parser on the value to validate this and will throw an exception if that parser fails. Note that the parser is less forgiving than many browsers. That is browsers will silently accept or drop many illegal constructs. We prefer to raise on them, so that errors are detected earlier.

It is recommended to use one of the other constructors instead if they are available. If they are not, consider adding them to this library.

val empty : t
val is_empty : t -> bool
val position : ?⁠top:Length.t -> ?⁠bottom:Length.t -> ?⁠left:Length.t -> ?⁠right:Length.t -> [ `Static | `Absolute | `Sticky | `Relative | `Fixed ] -> t

Set the position attribute and optionally top, bottom,left,right Note that left and top have no effect when position is `Static.

val top : Length.t -> t

Add the top property alone.

val bottom : Length.t -> t

Add the bottom property alone.

val left : Length.t -> t

Add the left property alone.

val right : Length.t -> t

Add the right property alone.

val combine : t -> t -> t

Neither combine nor concat validate that each t is unique. For combine x y, y will override x if they are the same attribute. For concat l, the greatest index of an attribute will prevail.

val (@>) : t -> t -> t
val concat : t list -> t
val to_string_list : t -> (string * string) list
val to_string_css : t -> string
val of_string_css_exn : string -> t

The inverse of to_string_css. Primarily useful if you want to reuse a css literal from the web (aka copy paste web design). Raises if the string fails validation. See create for comments on the validation we do.

val box_sizing : [ `Content_box | `Border_box | css_global_values ] -> t
val display : [ `Inline | `Block | `Inline_block | `List_item | `Table | `Inline_table | `None | css_global_values ] -> t
val visibility : [ `Visible | `Hidden | `Collapse | css_global_values ] -> t
type overflow = [
| `Visible
| `Hidden
| `Scroll
| `Auto
| css_global_values
]
val overflow : overflow -> t
val overflow_x : overflow -> t
val overflow_y : overflow -> t
val z_index : int -> t
val opacity : float -> t
type font_style = [
| `Normal
| `Italic
| `Oblique
| css_global_values
]
type font_weight = [
| `Normal
| `Bold
| `Bolder
| `Lighter
| `Number of int
| css_global_values
]
type font_variant = [
| `Normal
| `Small_caps
| css_global_values
]
val font_size : Length.t -> t
val font_family : string list -> t
val font_style : font_style -> t
val font_weight : font_weight -> t
val font_variant : font_variant -> t
val font : size:Length.t -> family:string list -> ?⁠style:font_style -> ?⁠weight:font_weight -> ?⁠variant:font_variant -> unit -> t
val bold : t
type stops = (Core_kernel.Percent.t * Color.t) list
type linear_gradient = {
direction : [ `Deg of int ];
stops : stops;
}
type radial_gradient = {
stops : stops;
}
type background_image = [
| `Url of string
| `Linear_gradient of linear_gradient
| `Radial_gradient of radial_gradient
]
val color : Color.t -> t
val background_color : Color.t -> t
val background_image : background_image -> t
val text_align : [ `Left | `Right | `Center | `Justify | css_global_values ] -> t
val horizontal_align : [ `Left | `Right | `Center | css_global_values ] -> t
val vertical_align : [ `Top | `Bottom | `Middle | css_global_values ] -> t
val white_space : [ `Normal | `Nowrap | `Pre | `Pre_line | `Pre_wrap | css_global_values ] -> t
val float : [ `None | `Left | `Right | css_global_values ] -> t
val width : Length.t -> t
val min_width : Length.t -> t
val max_width : Length.t -> t
val height : Length.t -> t
val min_height : Length.t -> t
val max_height : Length.t -> t
val padding_top : Length.t -> t
val padding_bottom : Length.t -> t
val padding_left : Length.t -> t
val padding_right : Length.t -> t
val uniform_padding : Length.t -> t
val padding : ?⁠top:Length.t -> ?⁠bottom:Length.t -> ?⁠left:Length.t -> ?⁠right:Length.t -> unit -> t
val margin_top : Auto_or_length.t -> t
val margin_bottom : Auto_or_length.t -> t
val margin_left : Auto_or_length.t -> t
val margin_right : Auto_or_length.t -> t
val uniform_margin : Auto_or_length.t -> t
val margin : ?⁠top:Auto_or_length.t -> ?⁠bottom:Auto_or_length.t -> ?⁠left:Auto_or_length.t -> ?⁠right:Auto_or_length.t -> unit -> t
type border_style = [
| `None
| `Hidden
| `Dotted
| `Dashed
| `Solid
| `Double
| `Groove
| `Ridge
| `Inset
| `Outset
| css_global_values
]
val border_top : ?⁠width:Length.t -> ?⁠color:Color.t -> style:border_style -> unit -> t
val border_bottom : ?⁠width:Length.t -> ?⁠color:Color.t -> style:border_style -> unit -> t
val border_left : ?⁠width:Length.t -> ?⁠color:Color.t -> style:border_style -> unit -> t
val border_right : ?⁠width:Length.t -> ?⁠color:Color.t -> style:border_style -> unit -> t
val border : ?⁠width:Length.t -> ?⁠color:Color.t -> style:border_style -> unit -> t
val border_radius : Length.t -> t
val border_collapse : [ `Separate | `Collapse | css_global_values ] -> t
val border_spacing : Length.t -> t
val outline : ?⁠width:Length.t -> ?⁠color:Color.t -> style:border_style -> unit -> t
type text_decoration_line = [
| `None
| `Underline
| `Overline
| `Line_through
| css_global_values
]
type text_decoration_style = [
| `Solid
| `Double
| `Dotted
| `Dashed
| `Wavy
| css_global_values
]
val text_decoration : ?⁠style:text_decoration_style -> ?⁠color:Color.t -> line:text_decoration_line list -> unit -> t
type item_alignment = [
| `Auto
| `Flex_start
| `Flex_end
| `Center
| `Baseline
| `Stretch
]
val flex_container : ?⁠inline:bool -> ?⁠direction:[ `Row | `Row_reverse | `Column | `Column_reverse ] -> ?⁠wrap:[ `Nowrap | `Wrap | `Wrap_reverse ] -> ?⁠align_items:item_alignment -> unit -> t
val flex_item : ?⁠order:int -> ?⁠basis:Auto_or_length.t -> ?⁠shrink:float -> grow:float -> unit -> t
val align_self : item_alignment -> t
val animation : name:string -> duration:Core_kernel.Time_ns.Span.t -> ?⁠delay:Core_kernel.Time_ns.Span.t -> ?⁠direction:[ `Normal | `Reverse | `Alternate | `Alternate_reverse | css_global_values ] -> ?⁠fill_mode:[ `None | `Forwards | `Backwards | `Both | css_global_values ] -> ?⁠iter_count:int -> ?⁠timing_function:string -> unit -> t

Note: You must include the names @keyframes in the stylesheet

module Stable : sig ... end