CssTyped CSS construction.
This library provides types and functions to construct CSS declarations, rules and stylesheets. It avoids stringly-typed CSS by keeping close to the CSS syntax and specifications.
The main notions are:
declaration is a property/value pair.t is a stylesheet (sequence of rules and at-rules; internal representation is not exposed).length, color); invalid constructs raise Invalid_argument.Minimal example:
open Css
(* Build a ".btn" rule and render a stylesheet from it. *)
let button =
rule ~selector:(Selector.class_ "btn")
[ display Inline_block
; background_color (hex "#3b82f6")
; color (hex "#ffffff")
; padding (Rem 0.5)
; border_radius (Rem 0.375)
]
in
to_string (v [ button ])Custom properties:
let def, v = var "primary-color" Color (hex "#3b82f6") in
let root = rule ~selector:(Selector.pseudo_class "root") [ def ] in
let card = rule ~selector:(Selector.class_ "card") [ color (Var v) ] in
to_string (v [ root; card ])Interface
Core Concepts - Core CSS system setup and construction:
Declarations - Core value types and declaration building:
Property Categories - Organized CSS properties by functionality:
Rendering & Optimization - CSS output and performance:
Advanced Features - Specialized functionality:
See https://www.w3.org/Style/CSS/specs.en.html W3C CSS Specifications and https://developer.mozilla.org/en-US/docs/Web/CSS MDN CSS Documentation.
Core CSS system setup and construction tools for building stylesheets.
Structured representation of CSS selectors for targeting HTML elements.
See https://www.w3.org/TR/selectors-4/ CSS Selectors Level 4.
module Selector : sig ... endCSS selectors: core types and helpers.
Core building blocks for CSS rules and stylesheet construction.
See https://www.w3.org/TR/css-syntax-3/ CSS Syntax Module Level 3.
val rule :
selector:Selector.t ->
?nested:statement list ->
declaration list ->
statementrule ~selector declarations creates a CSS rule statement with the given selector and declarations.
val statement_selector : statement -> Selector.t optionstatement_selector stmt returns Some selector if the statement is a rule, None otherwise.
val statement_declarations : statement -> declaration list optionstatement_declarations stmt returns Some declarations if the statement is a rule, None otherwise.
val as_rule :
statement ->
(Selector.t * declaration list * statement list) optionas_rule stmt returns Some (selector, declarations, nested) if the statement is a rule, None otherwise.
as_layer stmt returns Some (name, statements) if the statement is a layer, None otherwise.
as_media stmt returns Some (condition, statements) if the statement is a media query, None otherwise.
as_container stmt returns Some (name, condition, statements) if the statement is a container query, None otherwise.
as_supports stmt returns Some (condition, statements) if the statement is a supports query, None otherwise.
val is_nested_media : statement -> boolis_nested_media stmt returns true if the statement is a media query containing bare declarations (CSS nesting style), false otherwise.
val as_declarations : statement -> declaration list optionas_declarations stmt returns Some decls if the statement is a bare declarations block (used in CSS nesting), None otherwise.
val map :
(Selector.t -> declaration list -> statement) ->
statement list ->
statement listmap f stmts applies f to all rules in stmts, recursively descending into nested containers (media, supports, layers, etc.).
val sort :
((Selector.t * declaration list) -> (Selector.t * declaration list) -> int) ->
statement list ->
statement listsort cmp stmts sorts rules within stmts using the comparison function cmp, recursively descending into nested containers.
Existential type for property information that preserves type safety
val as_property : statement -> property_info optionas_property stmt returns Some (Property_info {...}) if the statement is a @property declaration, None otherwise. The existential type preserves the relationship between syntax type and initial value type.
keyframes name frames creates a @keyframes rule.
Example:
keyframes "pulse"
[
{
keyframe_selector = "50%";
keyframe_declarations = [ opacity (Float 0.5) ];
};
]produces @keyframes pulse { 50% { opacity: 0.5 } }.
as_keyframes stmt returns Some (name, frames) if the statement is a @keyframes animation, None otherwise.
val as_font_face : statement -> Stylesheet.font_face_descriptor list optionas_font_face stmt returns Some descriptors if the statement is a @font-face rule, None otherwise.
At-rules are CSS statements that instruct CSS how to behave. They begin with an at sign (@) followed by an identifier and include everything up to the next semicolon or CSS block.
See https://www.w3.org/TR/css-conditional-3/ CSS Conditional Rules Module Level 3 and https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule MDN At-rules.
Tools for building complete CSS stylesheets from rules and declarations.
val empty : tempty is an empty stylesheet.
rule_statements t returns the top-level rule statements from the stylesheet.
statements t returns all top-level statements from the stylesheet.
fold f acc css folds over all statements in css, recursively descending into nested structures (layers, media queries, containers, and supports rules). The function f is called for each statement in depth-first order.
Example: Collect all selectors from all rules (including nested ones):
let selectors =
Css.fold
(fun acc stmt ->
match Css.as_rule stmt with
| Some (sel, _, _) -> Css.Selector.to_string sel :: acc
| None -> acc)
[] cssmedia_queries t returns media queries and their rule statements.
val layers : t -> string listlayers t returns the layer names from the stylesheet.
layer_block name sheet extracts the statements from the named layer @layer name in the stylesheet. Returns None if the layer is not found.
val rules_from_statements :
statement list ->
(Selector.t * declaration list) listrules_from_statements stmts extracts all CSS rules (selector + declarations) from a list of statements, filtering out at-rules and other non-rule statements.
val custom_prop_names : declaration list -> string listcustom_prop_names decls extracts all custom property names from a list of declarations.
val custom_props_from_rules :
(Selector.t * declaration list) list ->
string listcustom_props_from_rules rules extracts all custom property names from the declarations in the rules.
val custom_props : ?layer:string -> t -> string listcustom_props ?layer sheet recursively extracts all custom property names from the stylesheet. If layer is provided, only properties from that layer are extracted. Traverses nested @supports, @media, and other conditional blocks.
media ~condition statements creates a @media statement with the given condition.
val media_nested : condition:Media.t -> declaration list -> statementmedia_nested ~condition declarations creates a @media statement for CSS nesting, containing bare declarations (no selector). Used inside rules where the selector is inherited from the parent.
val declarations : declaration list -> statementdeclarations decls creates a bare declarations block (used in CSS nesting).
layer ?name statements creates a @layer statement with the given statements.
val layer_decl : string list -> statementlayer_decl names creates a @layer declaration statement that declares layer names without any content (e.g., @layer theme, base, components, utilities;).
layer_of ?name stylesheet wraps an entire stylesheet in @layer, preserving @supports and other at-rules within it.
container ?name ~condition statements creates a @container statement with the given statements.
supports ~condition statements creates a @supports statement with the given condition.
starting_style statements creates a @starting-style statement with the given statements. Used for CSS entry animations.
val starting_style_nested : declaration list -> statementstarting_style_nested declarations creates a @starting-style statement for CSS nesting, containing bare declarations (no selector). Used inside rules where the selector is inherited from the parent.
Core value types and declaration building blocks.
val var_name : 'a var -> stringvar_name v is v's variable name (without --).
val var_layer : 'a var -> string optionvar_layer v is the optional layer where v is defined.
with_fallback var_ref fallback_value creates a new variable reference with the same variable name but a different fallback value. This is useful when you need to reference a variable from another module with a specific fallback, without creating a declaration.
vars_of_rules statements extracts all CSS variables referenced in rule statements' declarations, returning them sorted and deduplicated.
val vars_of_declarations : declaration list -> any_var listvars_of_declarations decls extracts all CSS variables referenced in the declarations list.
vars_of_stylesheet stylesheet extracts all CSS variables referenced in the entire stylesheet, returning them sorted and deduplicated.
val any_var_name : any_var -> stringany_var_name v is the name of a CSS variable (with -- prefix).
val custom_declarations : ?layer:string -> declaration list -> declaration listcustom_declarations ?layer decls is only the custom property declarations from decls. If layer is provided, only declarations from that layer are returned.
Fundamental types for CSS values, variables, and calculations that underpin the entire CSS system.
See https://www.w3.org/TR/css-variables-1/ CSS Custom Properties for Cascading Variables Module Level 1 and https://www.w3.org/TR/css-values-3/ CSS Values and Units Module Level 3.
Core value types used across CSS properties.
See https://www.w3.org/TR/css-values-4/ CSS Values and Units Module Level 4.
type length = | Px of float| Cm of float| Mm of float| Q of float| In of float| Pt of float| Pc of float| Rem of float| Em of float| Ex of float| Cap of float| Ic of float| Rlh of float| Pct of float| Vw of float| Vh of float| Vmin of float| Vmax of float| Vi of float| Vb of float| Dvh of float| Dvw of float| Dvmin of float| Dvmax of float| Lvh of float| Lvw of float| Lvmin of float| Lvmax of float| Svh of float| Svw of float| Svmin of float| Svmax of float| Ch of floatCharacter units
*)| Lh of floatLine height units
*)| Auto| Nonenone keyword (e.g., for max-width)
*)| Zero| Inherit| Initial| Unset| Revert| Revert_layer| Fit_contentfit-content keyword
*)| Contentcontent keyword
*)| Max_contentmax-content keyword
*)| Min_contentmin-content keyword
*)| From_fontfrom-font keyword for text-decoration-thickness
*)| Clamp of stringclamp() function
*)| Min of stringmin() function
*)| Max of stringmax() function
*)| Minmax of stringminmax() function for grid
*)| Var of length varCSS variable reference
*)| Calc of length calcCalculated expressions
*)CSS length values.
Supports absolute, relative, viewport (including dynamic/large/small), character-based units, keywords, and calculated expressions.
module Calc : sig ... endBuilder functions for calc() expressions.
type color_name = | Red| Blue| Green| White| Black| Yellow| Cyan| Magenta| Gray| Grey| Orange| Purple| Pink| Silver| Maroon| Fuchsia| Lime| Olive| Teal| Aqua| Alice_blue| Antique_white| Aquamarine| Azure| Beige| Bisque| Blanched_almond| Blue_violet| Brown| Burlywood| Cadet_blue| Chartreuse| Chocolate| Coral| Cornflower_blue| Cornsilk| Crimson| Dark_blue| Dark_cyan| Dark_goldenrod| Dark_gray| Dark_green| Dark_grey| Dark_khaki| Dark_magenta| Dark_olive_green| Dark_orange| Dark_orchid| Dark_red| Dark_salmon| Dark_sea_green| Dark_slate_blue| Dark_slate_gray| Dark_slate_grey| Dark_turquoise| Dark_violet| Deep_pink| Deep_sky_blue| Dim_gray| Dim_grey| Dodger_blue| Firebrick| Floral_white| Forest_green| Gainsboro| Ghost_white| Gold| Goldenrod| Green_yellow| Honeydew| Hot_pink| Indian_red| Indigo| Ivory| Khaki| Lavender| Lavender_blush| Lawn_green| Lemon_chiffon| Light_blue| Light_coral| Light_cyan| Light_goldenrod_yellow| Light_gray| Light_green| Light_grey| Light_pink| Light_salmon| Light_sea_green| Light_sky_blue| Light_slate_gray| Light_slate_grey| Light_steel_blue| Light_yellow| Lime_green| Linen| Medium_aquamarine| Medium_blue| Medium_orchid| Medium_purple| Medium_sea_green| Medium_slate_blue| Medium_spring_green| Medium_turquoise| Medium_violet_red| Midnight_blue| Mint_cream| Misty_rose| Moccasin| Old_lace| Olive_drab| Orange_red| Orchid| Pale_goldenrod| Pale_green| Pale_turquoise| Pale_violet_red| Papaya_whip| Peach_puff| Peru| Plum| Powder_blue| Rebecca_purple| Rosy_brown| Royal_blue| Saddle_brown| Salmon| Sandy_brown| Sea_green| Sea_shell| Sienna| Sky_blue| Slate_blue| Slate_gray| Slate_grey| Snow| Spring_green| Steel_blue| Tan| Thistle| Tomato| Turquoise| Violet| Wheat| White_smoke| Yellow_greenCSS named colors as defined in the CSS Color Module specification.
CSS channel values (for RGB)
CSS percentage values
type length_percentage = | Length of length| Pct of float| Var of length_percentage var| Calc of length_percentage calctype number_percentage = | Num of float| Pct of float| Var of number_percentage var| Calc of number_percentage calcCSS number or percentage values (for properties like scale, brightness)
CSS hue interpolation options
type system_color = | AccentColorBackground of accented user interface controls
*)| AccentColorTextText of accented user interface controls
*)| ActiveTextText of active links
*)| ButtonBorderBase border color of controls
*)| ButtonFaceBackground color of controls
*)| ButtonTextText color of controls
*)| CanvasBackground of application content or documents
*)| CanvasTextText color in application content or documents
*)| FieldBackground of input fields
*)| FieldTextText in input fields
*)| GrayTextText color for disabled items
*)| HighlightBackground of selected items
*)| HighlightTextText color of selected items
*)| LinkTextText of non-active, non-visited links
*)| MarkBackground of specially marked text
*)| MarkTextText that has been specially marked
*)| SelectedItemBackground of selected items (e.g., selected checkbox)
*)| SelectedItemTextText of selected items
*)| VisitedTextText of visited links
*)| Webkit_focus_ring_colorWebKit-specific focus ring color
*)CSS system colors - case-insensitive keywords that map to OS/browser colors. These are semantic colors that adapt to user preferences and system settings.
type color = | Hex of {}hash indicates if # was present
*)| Rgb of rgb| Rgba of {}| Hsl of {h : hue;s : percentage;l : percentage;a : alpha;}| Hwb of {h : hue;w : percentage;b : percentage;a : alpha;}| Color of {space : color_space;components : component list;alpha : alpha;}| Oklch of {l : percentage;c : float;h : hue;alpha : alpha;}OKLCH color space
*)| Oklab of {l : percentage;a : float;b : float;alpha : alpha;}Oklab color space
*)| Lch of {l : percentage;c : float;h : hue;alpha : alpha;}LCH color space
*)| Named of color_nameNamed colors like Red, Blue, etc.
*)| System of system_colorCSS system colors like ButtonText, Canvas, etc.
*)| Var of color var| Current| Transparent| Inherit| Initial| Unset| Revert| Revert_layer| Mix of {in_space : color_space option;hue : hue_interpolation;color1 : color;percent1 : percentage option;color2 : color;percent2 : percentage option;}CSS color values.
val hex : string -> colorhex s is a hexadecimal color. Accepts with or without leading #. Examples: hex "#3b82f6", hex "ffffff".
val rgb : ?alpha:float -> int -> int -> int -> colorrgb ?alpha r g b is an RGB color (0–255 components) with optional alpha.
val hsl : float -> float -> float -> colorhsl h s l is an HSL color with h in degrees, s and l in percentages (0-100).
val hsla : float -> float -> float -> float -> colorhsla h s l a is an HSLA color with alpha in 0., 1..
val hwb : float -> float -> float -> colorhwb h w b is an HWB color with h in degrees, w and b in percentages (0-100).
val hwba : float -> float -> float -> float -> colorhwba h w b a is an HWB color with alpha in 0., 1..
val oklch : float -> float -> float -> coloroklch l c h is an OKLCH color. L in percentage (0-100), h in degrees.
val oklcha : float -> float -> float -> float -> coloroklcha l c h a is an OKLCH color with alpha in 0., 1..
val oklab : float -> float -> float -> coloroklab l a b is an OKLAB color. L in percentage (0-100).
val oklaba : float -> float -> float -> float -> coloroklaba l a b alpha is an OKLAB color with alpha in 0., 1..
val lch : float -> float -> float -> colorlch l c h is an LCH color. L in percentage (0-100), h in degrees.
val lcha : float -> float -> float -> float -> colorlcha l c h a is an LCH color with alpha in 0., 1..
val color_name : color_name -> colorcolor_name n is a named color as defined in the CSS Color specification.
val current_color : colorcurrent_color is the CSS currentcolor value.
val transparent : colortransparent is the CSS transparent value.
val color_mix :
?in_space:color_space ->
?hue:hue_interpolation ->
?percent1:int ->
?percent2:int ->
color ->
color ->
colorcolor_mix ?in_space ?percent1 ?percent2 c1 c2 is a color-mix value. Defaults: in_space = Srgb, percent1 = None, percent2 = None.
type blend_mode = | Normal| Multiply| Screen| Overlay| Darken| Lighten| Color_dodge| Color_burn| Hard_light| Soft_light| Difference| Exclusion| Hue| Saturation| Color| Luminosity| Plus_darker| Plus_lighter| Var of blend_mode varCSS blend-mode values
type font_feature_settings = | Normal| Feature_list of string| Inherit| String of string| Var of font_feature_settings varCSS font-feature-settings values
type font_variation_settings = | Normal| Axis_list of string| Inherit| String of string| Var of font_variation_settings varCSS font-variation-settings values
val important : declaration -> declarationimportant decl is decl marked as !important.
val declaration_is_important : declaration -> booldeclaration_is_important decl returns true if decl has the !important flag.
val declaration_name : declaration -> stringdeclaration_name decl returns the property name of decl.
val declaration_value : ?minify:bool -> ?inline:bool -> declaration -> stringdeclaration_value ~minify ~inline decl returns the value of decl as a string. If minify is true (default: false), the output is minified. If inline is true (default: false), variables are resolved to their default values.
val string_of_declaration : ?minify:bool -> declaration -> stringstring_of_declaration ~minify decl converts a declaration to its string representation. If minify is true (default: false), the output is minified.
CSS properties organized by functionality and usage patterns.
The CSS Box Model defines how element dimensions are calculated and how space is distributed around content. This includes width/height properties, padding, margins, and box sizing behavior.
val width : length -> declarationwidth len is the width property.
val height : length -> declarationheight len is the height property.
val min_width : length -> declarationmin_width len is the min-width property.
val max_width : length -> declarationmax_width len is the max-width property.
val min_height : length -> declarationmin_height len is the min-height property.
val max_height : length -> declarationmax_height len is the max-height property.
val padding : length list -> declarationpadding values is the padding shorthand property. Accepts 1-4 values.
val padding_top : length -> declarationpadding_top len is the padding-top property.
val padding_right : length -> declarationpadding_right len is the padding-right property.
val padding_bottom : length -> declarationpadding_bottom len is the padding-bottom property.
val padding_left : length -> declarationpadding_left len is the padding-left property.
val margin : length list -> declarationmargin values is the margin shorthand property. Accepts 1-4 values.
val margin_top : length -> declarationmargin_top len is the margin-top property.
val margin_right : length -> declarationmargin_right len is the margin-right property.
val margin_bottom : length -> declarationmargin_bottom len is the margin-bottom property.
val margin_left : length -> declarationmargin_left len is the margin-left property.
val box_sizing : box_sizing -> declarationbox_sizing sizing is the box-sizing property.
val field_sizing : field_sizing -> declarationfield_sizing sizing is the field-sizing property.
val caption_side : caption_side -> declarationcaption_side side is the caption-side property.
val aspect_ratio : aspect_ratio -> declarationaspect_ratio ratio is the aspect-ratio property.
CSS Logical Properties provide writing-mode-relative property equivalents for physical properties. These adapt to different writing directions and text orientations.
type border_width = | Thin| Medium| Thick| Px of float| Rem of float| Em of float| Ch of float| Vh of float| Vw of float| Vmin of float| Vmax of float| Pct of float| Zero| Auto| Max_content| Min_content| Fit_content| From_font| Calc of border_width calc| Var of border_width var| Inheritval border_inline_start_width : border_width -> declarationborder_inline_start_width len is the border-inline-start-width property.
val border_inline_end_width : border_width -> declarationborder_inline_end_width len is the border-inline-end-width property.
val border_inline_start_color : color -> declarationborder_inline_start_color c is the border-inline-start-color property.
val border_inline_end_color : color -> declarationborder_inline_end_color c is the border-inline-end-color property.
val padding_inline_start : length -> declarationpadding_inline_start len is the padding-inline-start property.
val padding_inline_end : length -> declarationpadding_inline_end len is the padding-inline-end property.
val padding_inline : length -> declarationpadding_inline len is the padding-inline shorthand property.
val padding_block : length -> declarationpadding_block len is the padding-block shorthand property.
val margin_inline : length -> declarationmargin_inline len is the margin-inline property with a length value.
val margin_inline_start : length -> declarationmargin_inline_start len is the margin-inline-start property.
val margin_inline_end : length -> declarationmargin_inline_end len is the margin-inline-end property.
val margin_block : length -> declarationmargin_block len is the margin-block property with a length value.
val margin_block_start : length -> declarationmargin_block_start len is the margin-block-start property.
val margin_block_end : length -> declarationmargin_block_end len is the margin-block-end property.
Controls how elements are displayed and positioned in the document flow. This includes the display model, positioning schemes, and stacking context.
val display : display -> declarationdisplay d is the display property.
val position : position -> declarationposition p is the position property.
val inset : length -> declarationinset len is the inset property for positioned elements.
val inset_inline : length -> declarationinset_inline len is the inset-inline logical property.
val inset_inline_start : length -> declarationinset_inline_start len is the inset-inline-start logical property.
val inset_inline_end : length -> declarationinset_inline_end len is the inset-inline-end logical property.
val inset_block : length -> declarationinset_block len is the inset-block logical property.
val inset_block_start : length -> declarationinset_block_start len is the inset-block-start logical property.
val inset_block_end : length -> declarationinset_block_end len is the inset-block-end logical property.
val top : length -> declarationtop len is the top property for positioned elements.
val right : length -> declarationright len is the right property for positioned elements.
val bottom : length -> declarationbottom len is the bottom property for positioned elements.
val left : length -> declarationleft len is the left property for positioned elements.
val z_index : z_index -> declarationz_index z is the z-index property.
val z_index_auto : declarationz_index_auto is the z-index property set to auto.
val isolation : isolation -> declarationisolation iso is the isolation property for stacking context control.
val visibility : visibility -> declarationvisibility v is the visibility property.
val float : float_side -> declarationfloat side is the float property.
val clear : clear -> declarationclear clr is the clear property.
val overflow : overflow -> declarationoverflow ov is the overflow property.
val overflow_x : overflow -> declarationoverflow_x ov is the overflow-x property.
val overflow_y : overflow -> declarationoverflow_y ov is the overflow-y property.
CSS content values
val content : content -> declarationcontent c is the content property.
val object_fit : object_fit -> declarationobject_fit fit is the object-fit property.
val object_position : position_value -> declarationobject_position pos is the object-position property.
val text_overflow : text_overflow -> declarationtext_overflow ov is the text-overflow property.
val text_wrap : text_wrap -> declarationtext_wrap wrap is the text-wrap property.
val backface_visibility : backface_visibility -> declarationbackface_visibility vis is the backface-visibility property (3D transforms).
type content_visibility = | VisibleContent is visible and rendered
*)| HiddenContent is hidden from rendering
*)| AutoBrowser determines visibility based on relevance
*)| InheritInherit from parent
*)| Var of content_visibility varCSS variable reference
*)CSS content-visibility values.
val content_visibility : content_visibility -> declarationcontent_visibility vis is the content-visibility property.
val quotes : quotes -> declarationquotes q is the quotes property.
val list_style_position : list_style_position -> declarationlist_style_position pos is the list-style-position property.
Properties for controlling foreground colors, background colors, images, and related visual styling for element backgrounds.
type background_repeat = | Repeat| Space| Round| No_repeat| Repeat_x| Repeat_y| Repeat_repeat| Repeat_space| Repeat_round| Repeat_no_repeat| Space_repeat| Space_space| Space_round| Space_no_repeat| Round_repeat| Round_space| Round_round| Round_no_repeat| No_repeat_repeat| No_repeat_space| No_repeat_round| No_repeat_no_repeat| Inherit| Initial| UnsetCSS background-repeat values.
Color interpolation for gradients
type gradient_direction = | To_top| To_top_right| To_right| To_bottom_right| To_bottom| To_bottom_left| To_left| To_top_left| Angle of angle| With_interpolation of gradient_direction * color_interpolation| Var of gradient_direction varGradient direction values
type gradient_stop = | Var of gradient_stop varSingle complex variable like var(--complex, fallback)
*)| Color_percentage of color * percentage option * percentage optionColor with optional percentage positions
*)| Color_length of color * length option * length optionColor with optional length positions
*)| Length of lengthInterpolation hint with length, e.g., "50px"
*)| List of gradient_stop listMultiple gradient stops - used for var fallbacks
*)| Percentage of percentageInterpolation hint with percentage, e.g., "50%"
*)| Direction of gradient_directionGradient direction for stops, e.g., "to right" or Var
*)Gradient stop values
type background_image = | Url of string| Linear_gradient of gradient_direction * gradient_stop list| Linear_gradient_var of gradient_stop varLinear gradient using a single variable for all stops including position. Outputs: linear-gradient(var(--tw-gradient-stops))
*)| Radial_gradient of gradient_stop list| None| Initial| InheritBackground image values
type background_shorthand = {color : color option;image : background_image option;position : position_value option;size : background_size option;repeat : background_repeat option;attachment : background_attachment option;clip : background_box option;origin : background_box option;}CSS background shorthand values.
type background = | Inherit| Initial| Unset| None| Var of background var| Shorthand of background_shorthandCSS background values.
*)val background_shorthand :
?color:color ->
?image:background_image ->
?position:position_value ->
?size:background_size ->
?repeat:background_repeat ->
?attachment:background_attachment ->
?clip:background_box ->
?origin:background_box ->
unit ->
backgroundbackground_shorthand ?color ?image ?position ?size ?repeat ?attachment ?clip ?origin () is the background shorthand.
color: background colorimage: background image (url or gradient)position: image positionsize: image size (cover, contain, or specific size)repeat: repeat behavior (repeat, no-repeat, etc.)attachment: scroll behavior (scroll, fixed, local)clip: clipping areaorigin: positioning area.val color : color -> declarationcolor c is the color property.
val background : background -> declarationbackground bg is the background shorthand property.
val background_color : color -> declarationbackground_color c is the background-color property.
val background_image : background_image -> declarationbackground_image img is the background-image property.
val background_position : position_value list -> declarationbackground_position pos is the background-position property.
val background_size : background_size -> declarationbackground_size sz is the background-size property.
val background_repeat : background_repeat -> declarationbackground_repeat rep is the background-repeat property.
val background_attachment : background_attachment -> declarationbackground_attachment att is the background-attachment property.
val opacity : float -> declarationopacity op is the opacity property.
val url : string -> background_imageurl path is a URL background image value.
val linear_gradient :
gradient_direction ->
gradient_stop list ->
background_imagelinear_gradient dir stops is a linear gradient background.
val radial_gradient : gradient_stop list -> background_imageradial_gradient stops is a radial gradient background.
val color_stop : color -> gradient_stopcolor_stop c is a simple color stop.
val color_position : color -> length -> gradient_stopcolor_position c pos is a color stop at a specific position.
Properties for CSS Flexible Box Layout, a one-dimensional layout method for distributing space between items and providing alignment capabilities.
type flex_basis = | Auto| Content| Px of float| Cm of float| Mm of float| Q of float| In of float| Pt of float| Pc of float| Rem of float| Em of float| Ex of float| Cap of float| Ic of float| Rlh of float| Pct of float| Vw of float| Vh of float| Vmin of float| Vmax of float| Vi of float| Vb of float| Dvh of float| Dvw of float| Dvmin of float| Dvmax of float| Lvh of float| Lvw of float| Lvmin of float| Lvmax of float| Svh of float| Svw of float| Svmin of float| Svmax of float| Ch of float| Lh of float| Num of float| Zero| Inherit| Initial| Unset| Revert| Revert_layer| Fit_content| Max_content| Min_content| From_font| Var of flex_basis var| Calc of flex_basis calcCSS flex basis values.
type flex = | Initial0 1 auto
*)| Auto1 1 auto
*)| None0 0 auto
*)| Grow of floatSingle grow value
*)| Basis of flex_basis1 1 <flex-basis>
*)| Grow_shrink of float * floatgrow shrink 0%
*)| Full of float * float * flex_basisgrow shrink basis
*)CSS flex shorthand values.
type align_content = | Normal| Baseline| First_baseline| Last_baseline| Center| Start| End| Flex_start| Flex_end| Left| Right| Safe_center| Safe_start| Safe_end| Safe_flex_start| Safe_flex_end| Safe_left| Safe_right| Unsafe_center| Unsafe_start| Unsafe_end| Unsafe_flex_start| Unsafe_flex_end| Unsafe_left| Unsafe_right| Space_between| Space_around| Space_evenly| StretchCSS align-content values. MDN: align-content
CSS align-items values. MDN: align-items
CSS justify-content values. MDN: justify-content
CSS align-self values. MDN: align-self
type justify_items = | Normal| Stretch| Baseline| First_baseline| Last_baseline| Center| Start| End| Self_start| Self_end| Flex_start| Flex_end| Left| Right| Safe_center| Safe_start| Safe_end| Safe_self_start| Safe_self_end| Safe_flex_start| Safe_flex_end| Safe_left| Safe_right| Unsafe_center| Unsafe_start| Unsafe_end| Unsafe_self_start| Unsafe_self_end| Unsafe_flex_start| Unsafe_flex_end| Unsafe_left| Unsafe_right| Anchor_center| LegacyCSS justify-items values. MDN: justify-items
type justify_self = | Auto| Normal| Stretch| Baseline| First_baseline| Last_baseline| Center| Start| End| Self_start| Self_end| Flex_start| Flex_end| Left| Right| Safe_center| Safe_start| Safe_end| Safe_self_start| Safe_self_end| Safe_flex_start| Safe_flex_end| Safe_left| Safe_right| Unsafe_center| Unsafe_start| Unsafe_end| Unsafe_self_start| Unsafe_self_end| Unsafe_flex_start| Unsafe_flex_end| Unsafe_left| Unsafe_right| Anchor_center| InheritCSS justify-self values. MDN: justify-self
CSS Box Alignment properties for flexbox and grid layouts.
val align_content : align_content -> declarationalign_content alignment is the align-content property. Sets how content is aligned along the cross axis. Common values: Normal, Baseline, Center, Start, End, Space_between, Stretch.
val justify_content : justify_content -> declarationjustify_content alignment is the justify-content property. Sets how content is aligned along the main axis. Common values: Normal, Center, Start, End, Space_between, Space_around, Stretch.
val align_items : align_items -> declarationalign_items alignment is the align-items property. Sets alignment for all items along the cross axis. Common values: Normal, Baseline, Center, Start, End, Stretch.
val align_self : align_self -> declarationalign_self alignment is the align-self property. Overrides align-items for an individual item. Common values: Auto, Normal, Baseline, Center, Start, End, Stretch.
val justify_items : justify_items -> declarationjustify_items justification is the justify-items property. Sets default justification for all items. Common values: Normal, Baseline, Center, Start, End, Stretch, Legacy.
val justify_self : justify_self -> declarationjustify_self justification is the justify-self property. Sets justification for an individual item on the inline (main) axis.
val flex_direction : flex_direction -> declarationflex_direction direction is the flex-direction property.
val flex_wrap : flex_wrap -> declarationflex_wrap wrap is the flex-wrap property.
val flex : flex -> declarationflex flex is the flex shorthand property.
val flex_grow : float -> declarationflex_grow amount is the flex-grow property.
val flex_shrink : float -> declarationflex_shrink amount is the flex-shrink property.
val flex_basis : length -> declarationflex_basis basis is the flex-basis property.
val order : int -> declarationorder order is the order property.
val gap : gap -> declarationgap gap is the gap property shorthand (applies to both row and column gaps).
val row_gap : length -> declarationrow_gap gap is the row-gap property.
val column_gap : length -> declarationcolumn_gap gap is the column-gap property.
Properties for CSS Grid Layout, a two-dimensional layout system optimized for user interface design with explicit row and column positioning.
type grid_template = | None| Px of float| Rem of float| Em of float| Pct of float| Vw of float| Vh of float| Vmin of float| Vmax of float| Zero| Fr of float| Auto| Min_content| Max_content| Inherit| Min_max of grid_template * grid_template| Fit_content of length| Repeat of int * grid_template list| Tracks of grid_template list| Named_tracks of (string option * grid_template) list| Subgrid| MasonryCSS grid template values
val grid_template_columns : grid_template -> declarationgrid_template_columns cols is the grid-template-columns property.
val grid_template_rows : grid_template -> declarationgrid_template_rows rows is the grid-template-rows property.
val grid_template_areas : string -> declarationgrid_template_areas areas is the grid-template-areas property.
val grid_template : grid_template -> declarationgrid_template template is the grid-template shorthand property.
val grid_auto_columns : grid_template -> declarationgrid_auto_columns cols is the grid-auto-columns property.
val grid_auto_rows : grid_template -> declarationgrid_auto_rows rows is the grid-auto-rows property.
val grid_auto_flow : grid_auto_flow -> declarationgrid_auto_flow flow is the grid-auto-flow property.
val grid_row_start : grid_line -> declarationgrid_row_start start is the grid-row-start property.
val grid_row_end : grid_line -> declarationgrid_row_end end_ is the grid-row-end property.
val grid_column_start : grid_line -> declarationgrid_column_start start is the grid-column-start property.
val grid_column_end : grid_line -> declarationgrid_column_end end_ is the grid-column-end property.
val grid_row : (grid_line * grid_line) -> declarationgrid_row (start, end) is the grid-row shorthand property.
val grid_column : (grid_line * grid_line) -> declarationgrid_column (start, end) is the grid-column shorthand property.
val grid_area : string -> declarationgrid_area area is the grid-area property.
type place_items = | Normal| Start| End| Center| Stretch| Align_justify of align_items * justify_items| InheritCSS place-items values
val place_items : place_items -> declarationplace_items items is the place-items shorthand property.
type place_content = | Normal| Start| End| Center| Stretch| Space_between| Space_around| Space_evenly| Align_justify of align_content * justify_content| InheritCSS place-content values
val place_content : place_content -> declarationplace_content content is the place-content shorthand property.
val place_self : (align_self * justify_self) -> declarationplace_self self_ is the place-self shorthand property.
Properties for controlling text appearance, fonts, and text layout. This includes font properties, text decoration, alignment, and spacing.
type font_weight = | Weight of int| Normal| Bold| Bolder| Lighter| Inherit| Var of font_weight varCSS variable reference
*)CSS font weight values.
CSS text align values.
type text_decoration_shorthand = {lines : text_decoration_line list;style : text_decoration_style option;color : color option;thickness : length option;}type text_decoration = | None| Shorthand of text_decoration_shorthand| Inherit| Var of text_decoration varval text_decoration_shorthand :
?lines:text_decoration_line list ->
?style:text_decoration_style ->
?color:color ->
?thickness:length ->
unit ->
text_decorationtext_decoration_shorthand ?lines ?style ?color ?thickness () is the text-decoration shorthand.
lines: decoration lines (underline, overline, line-through)style: line style (solid, double, dotted, dashed, wavy)color: decoration colorthickness: line thickness.type text_transform = | None| Capitalize| Uppercase| Lowercase| Full_width| Full_size_kana| Inherit| Var of text_transform varCSS text transform values.
CSS text-size-adjust values (including vendor prefixes).
type font_family = | Sans_serif| Serif| Monospace| Cursive| Fantasy| System_ui| Ui_sans_serif| Ui_serif| Ui_monospace| Ui_rounded| Emoji| Math| Fangsong| Inter| Roboto| Open_sans| Lato| Montserrat| Poppins| Source_sans_pro| Raleway| Oswald| Noto_sans| Ubuntu| Playfair_display| Merriweather| Lora| PT_sans| PT_serif| Nunito| Nunito_sans| Work_sans| Rubik| Fira_sans| Fira_code| JetBrains_mono| IBM_plex_sans| IBM_plex_serif| IBM_plex_mono| Source_code_pro| Space_mono| DM_sans| DM_serif_display| Bebas_neue| Barlow| Mulish| Josefin_sans| Helvetica| Helvetica_neue| Arial| Verdana| Tahoma| Trebuchet_ms| Times_new_roman| Times| Georgia| Cambria| Garamond| Courier_new| Courier| Lucida_console| SF_pro| SF_pro_display| SF_pro_text| SF_mono| NY| Segoe_ui| Segoe_ui_emoji| Segoe_ui_symbol| Apple_color_emoji| Noto_color_emoji| Android_emoji| Twemoji_mozilla| Menlo| Monaco| Consolas| Liberation_mono| SFMono_regular| Cascadia_code| Cascadia_mono| Victor_mono| Inconsolata| Hack| Inherit| Initial| Unset| Name of string| Var of font_family var| List of font_family listCSS font-family values
val font_family : font_family -> declarationfont_family fonts is the font-family property.
val font_families : font_family list -> declarationfont_families fonts is the font-family property from a comma-separated list.
val font_size : length -> declarationfont_size size is the font-size property.
val font_weight : font_weight -> declarationfont_weight weight is the font-weight property.
val font_style : font_style -> declarationfont_style style is the font-style property.
type line_height = | Normal| Px of float| Rem of float| Em of float| Pct of float| Num of float| Inherit| Var of line_height var| Calc of line_height calcCSS line-height values
val line_height : line_height -> declarationline_height height is the line-height property. Accepts Normal, Length values (e.g., `Length (Rem 1.5)`), Number values (e.g., `Num 1.5`), or Percentage values.
val letter_spacing : length -> declarationletter_spacing spacing is the letter-spacing property.
val word_spacing : length -> declarationword_spacing spacing is the word-spacing property.
val text_align : text_align -> declarationtext_align align is the text-align property.
val text_decoration : text_decoration -> declarationtext_decoration decoration is the text-decoration property.
val text_transform : text_transform -> declarationtext_transform transform is the text-transform property.
val text_indent : length -> declarationtext_indent indent is the text-indent property.
CSS white-space values
val white_space : white_space -> declarationwhite_space space is the white-space property.
val word_break : word_break -> declarationword_break break is the word-break property.
val text_decoration_color : color -> declarationtext_decoration_color color is the text-decoration-color property.
val text_size_adjust : text_size_adjust -> declarationtext_size_adjust adjust is the text-size-adjust property.
val text_decoration_style : text_decoration_style -> declarationtext_decoration_style style is the text-decoration-style property.
val text_decoration_line : text_decoration_line -> declarationtext_decoration_line line is the text-decoration-line property.
val text_underline_offset : length -> declarationtext_underline_offset offset is the text-underline-offset property.
val overflow_wrap : overflow_wrap -> declarationoverflow_wrap wrap is the overflow-wrap property.
val hyphens : hyphens -> declarationhyphens hyphens is the hyphens property.
val font_stretch : font_stretch -> declarationfont_stretch stretch is the font-stretch property.
type font_variant_numeric_token = | NormalReset to normal font variant
*)| Lining_nums| Oldstyle_nums| Proportional_nums| Tabular_nums| Diagonal_fractions| Stacked_fractions| Ordinal| Slashed_zero| Var of font_variant_numeric_token varVariable reference
*)CSS font-variant-numeric token values
type font_variant_numeric = | Normal| Tokens of font_variant_numeric_token list| Var of font_variant_numeric var| Composed of {ordinal : font_variant_numeric_token option;slashed_zero : font_variant_numeric_token option;numeric_figure : font_variant_numeric_token option;numeric_spacing : font_variant_numeric_token option;numeric_fraction : font_variant_numeric_token option;}CSS font-variant-numeric values
val font_variant_numeric : font_variant_numeric -> declarationfont_variant_numeric numeric is the font-variant-numeric property using a list of tokens or a composed value.
val font_variant_numeric_tokens :
font_variant_numeric_token list ->
font_variant_numericfont_variant_numeric_tokens tokens is a font-variant-numeric value from tokens.
val font_variant_numeric_composed :
?ordinal:font_variant_numeric_token ->
?slashed_zero:font_variant_numeric_token ->
?numeric_figure:font_variant_numeric_token ->
?numeric_spacing:font_variant_numeric_token ->
?numeric_fraction:font_variant_numeric_token ->
unit ->
font_variant_numericfont_variant_numeric_composed ... is a composed font-variant-numeric value using CSS variables for style composition.
val font_feature_settings : font_feature_settings -> declarationfont_feature_settings settings is the font-feature-settings property.
type shadow = | Shadow of {inset : bool;inset_var : string option;If set, outputs var(--<name>) before shadow values. Used by Tailwind's ring system for dynamic inset toggle.
*)h_offset : length;v_offset : length;blur : length option;spread : length option;color : color option;}| None| Inherit| Initial| Unset| Revert| Revert_layer| Var of shadow var| List of shadow listCSS shadow values
val shadow :
?inset:bool ->
?inset_var:string ->
?h_offset:length ->
?v_offset:length ->
?blur:length ->
?spread:length ->
?color:color ->
unit ->
shadowshadow ?inset ?inset_var ?h_offset ?v_offset ?blur ?spread ?color () is a shadow value with optional parameters. When inset_var is set, outputs var(--<name>) before the shadow values (used by Tailwind's ring system). Defaults: inset=false, inset_var=None, h_offset=0px, v_offset=0px, blur=0px, spread=0px, color=Transparent.
val inset_ring_shadow :
?h_offset:length ->
?v_offset:length ->
?blur:length ->
?spread:length ->
?color:color ->
unit ->
shadowinset_ring_shadow ?h_offset ?v_offset ?blur ?spread ?color () is an inset shadow value suitable for ring utilities. Defaults: h_offset=0px, v_offset=0px, blur=0px, spread=0px, color=Transparent.
val text_shadow : text_shadow -> declarationtext_shadow shadow is the text-shadow property.
val font : string -> declarationfont spec is the font shorthand property.
val direction : direction -> declarationdirection dir is the direction property.
CSS unicode-bidi values
val unicode_bidi : unicode_bidi -> declarationunicode_bidi bidi is the unicode-bidi property.
CSS writing-mode values
val writing_mode : writing_mode -> declarationwriting_mode mode is the writing-mode property.
val text_decoration_thickness : length -> declarationtext_decoration_thickness thick is the text-decoration-thickness property.
val text_decoration_skip_ink : text_decoration_skip_ink -> declarationtext_decoration_skip_ink skip is the text-decoration-skip-ink property.
Properties for styling element borders, outlines, and related decorative features including border radius for rounded corners.
type border_style = | None| Solid| Dashed| Dotted| Double| Groove| Ridge| Inset| Outset| Hidden| Var of border_style varCSS variable reference
*)CSS border style values.
type border_shorthand = {width : border_width option;style : border_style option;color : color option;}CSS border shorthand type.
CSS outline shorthand components.
CSS outline property values.
val border_shorthand :
?width:border_width ->
?style:border_style ->
?color:color ->
unit ->
borderborder_shorthand ?width ?style ?color () is the border shorthand.
width: border width (thin, medium, thick, or specific length)style: border style (solid, dashed, dotted, etc.)color: border color.val border :
?width:border_width ->
?style:border_style ->
?color:color ->
unit ->
declarationborder border is the border shorthand property.
val border_width : border_width -> declarationborder_width width is the border-width property.
val border_style : border_style -> declarationborder_style style is the border-style property.
val border_color : color -> declarationborder_color color is the border-color property.
val border_radius : length -> declarationborder_radius radius is the border-radius property.
val border_top_left_radius : length -> declarationborder_top_left_radius radius is the border-top-left-radius property.
val border_top_right_radius : length -> declarationborder_top_right_radius radius is the border-top-right-radius property.
val border_bottom_left_radius : length -> declarationborder_bottom_left_radius radius is the border-bottom-left-radius property.
val border_bottom_right_radius : length -> declarationborder_bottom_right_radius radius is the border-bottom-right-radius property.
val border_top : string -> declarationborder_top border is the border-top property.
val border_right : string -> declarationborder_right border is the border-right property.
val border_bottom : string -> declarationborder_bottom border is the border-bottom property.
val border_left : string -> declarationborder_left border is the border-left property.
val outline : outline -> declarationoutline outline is the outline property.
val outline_width : length -> declarationoutline_width width is the outline-width property.
val outline_style : outline_style -> declarationoutline_style style is the outline-style property.
val outline_color : color -> declarationoutline_color color is the outline-color property.
val outline_offset : length -> declarationoutline_offset offset is the outline-offset property.
val border_top_style : border_style -> declarationborder_top_style s is the border-top-style property.
val border_right_style : border_style -> declarationborder_right_style s is the border-right-style property.
val border_bottom_style : border_style -> declarationborder_bottom_style s is the border-bottom-style property.
val border_left_style : border_style -> declarationborder_left_style s is the border-left-style property.
val border_left_width : border_width -> declarationborder_left_width len is the border-left-width property.
val border_top_width : border_width -> declarationborder_top_width len is the border-top-width property.
val border_right_width : border_width -> declarationborder_right_width len is the border-right-width property.
val border_bottom_width : border_width -> declarationborder_bottom_width len is the border-bottom-width property.
val border_top_color : color -> declarationborder_top_color c is the border-top-color property.
val border_right_color : color -> declarationborder_right_color c is the border-right-color property.
val border_bottom_color : color -> declarationborder_bottom_color c is the border-bottom-color property.
val border_left_color : color -> declarationborder_left_color c is the border-left-color property.
val border_collapse : border_collapse -> declarationborder_collapse value is the border-collapse property.
Properties for 2D/3D transformations, CSS animations, and transitions. Based on multiple CSS specification modules for comprehensive animation support.
type transform = | Translate of length * length option| Translate_x of length| Translate_y of length| Translate_z of length| Translate_3d of length * length * length| Rotate of angle| Rotate_x of angle| Rotate_y of angle| Rotate_z of angle| Rotate_3d of float * float * float * angle| Scale of float * float option| Scale_x of float| Scale_y of float| Scale_z of float| Scale_3d of float * float * float| Skew of angle * angle option| Skew_x of angle| Skew_y of angle| Matrix of float * float * float * float * float * float| Matrix_3d of float
* float
* float
* float
* float
* float
* float
* float
* float
* float
* float
* float
* float
* float
* float
* float| Perspective of length| None| Inherit| Var of transform var| List of transform listCSS transform values
val transform : transform -> declarationtransform t is the transform property with a single transformation.
val transforms : transform list -> declarationtransforms ts is the transform property with multiple transformations.
type transform_origin = | Center| Left| Right| Top| Bottom| Left_top| Left_center| Left_bottom| Right_top| Right_center| Right_bottom| Center_top| Center_bottom| Top_left| Top_right| Bottom_left| Bottom_right| X of lengthSingle x-offset, y defaults to 50%.
*)| XY of length * length| XYZ of length * length * length| InheritTransform origin (2D or 3D).
*)val origin : length -> length -> transform_originorigin x y is a transform-origin helper for 2D positions.
val origin3d : length -> length -> length -> transform_originorigin3d x y z is a transform-origin helper for 3D positions.
val transform_origin : transform_origin -> declarationtransform_origin origin is the transform-origin property.
val rotate : angle -> declarationrotate angle is the rotate property.
val perspective : length -> declarationperspective perspective is the perspective property (3D transforms).
val perspective_origin : perspective_origin -> declarationperspective_origin origin is the perspective-origin property.
val transform_style : transform_style -> declarationtransform_style style is the transform-style property (3D transforms).
CSS steps direction values.
type timing_function = | Ease| Linear| Ease_in| Ease_out| Ease_in_out| Step_start| Step_end| Steps of int * steps_direction option| Cubic_bezier of float * float * float * float| Var of timing_function varCSS animation timing function values.
type transition_property = transition_property_value listCSS transition property (list of property values).
type transition_shorthand = {property : transition_property_value;duration : duration option;timing_function : timing_function option;delay : duration option;}CSS transition shorthand values.
type transition = | Inherit| Initial| None| Var of transition var| Shorthand of transition_shorthandCSS transition values.
*)val transition_shorthand :
?property:transition_property_value ->
?duration:duration ->
?timing_function:timing_function ->
?delay:duration ->
unit ->
transitiontransition_shorthand ?property ?duration ?timing_function ?delay () is the transition shorthand.
property: CSS property to transition (defaults to All)duration: transition durationtiming_function: easing function (ease, linear, ease-in, etc.)delay: delay before transition starts.val transition : transition -> declarationtransition transition is the transition property.
val transitions : transition list -> declarationtransitions values is the transition property from a comma-separated list.
val transition_timing_function : timing_function -> declarationtransition_timing_function tf is the transition-timing-function property.
val transition_duration : duration -> declarationtransition_duration dur is the transition-duration property.
val transition_delay : duration -> declarationtransition_delay delay is the transition-delay property.
val transition_property : transition_property -> declarationtransition_property v is the transition-property property.
val transition_behavior : Properties.transition_behavior -> declarationtransition_behavior v is the transition-behavior property.
CSS animation direction values
type animation_shorthand = {name : string option;duration : duration option;timing_function : timing_function option;delay : duration option;iteration_count : animation_iteration_count option;direction : animation_direction option;fill_mode : animation_fill_mode option;play_state : animation_play_state option;}CSS animation shorthand values
type animation = | Inherit| Initial| None| Var of animation var| Shorthand of animation_shorthandCSS animation values
*)val animation_shorthand :
?name:string ->
?duration:duration ->
?timing_function:timing_function ->
?delay:duration ->
?iteration_count:animation_iteration_count ->
?direction:animation_direction ->
?fill_mode:animation_fill_mode ->
?play_state:animation_play_state ->
unit ->
animationanimation_shorthand ?name ?duration ?timing_function ?delay ?iteration_count ?direction ?fill_mode ?play_state () is the animation shorthand.
name: animation nameduration: animation durationtiming_function: easing functiondelay: delay before animation startsiteration_count: number of iterations (or Infinite)direction: animation direction (normal, reverse, alternate, etc.)fill_mode: how styles apply before/after animationplay_state: running or paused.val animation : animation -> declarationanimation props is the animation shorthand property.
val animation_name : string -> declarationanimation_name name is the animation-name property.
val animation_duration : duration -> declarationanimation_duration dur is the animation-duration property.
val animation_timing_function : timing_function -> declarationanimation_timing_function tf is the animation-timing-function property.
val animation_delay : duration -> declarationanimation_delay delay is the animation-delay property.
val animation_iteration_count : animation_iteration_count -> declarationanimation_iteration_count count is the animation-iteration-count property.
val animation_direction : animation_direction -> declarationanimation_direction dir is the animation-direction property.
val animation_fill_mode : animation_fill_mode -> declarationanimation_fill_mode mode is the animation-fill-mode property.
val animation_play_state : animation_play_state -> declarationanimation_play_state state is the animation-play-state property.
Properties for visual effects including shadows, filters, clipping, and other advanced rendering features.
val box_shadow : shadow -> declarationbox_shadow shadow is the box-shadow property.
val box_shadows : shadow list -> declarationbox_shadows values is the box-shadow property.
CSS number values (unitless numbers for filters, transforms, etc.)
type scale = | X of number_percentage| XY of number_percentage * number_percentage| XYZ of number_percentage * number_percentage * number_percentage| None| Var of scale varCSS scale property values
val scale : scale -> declarationscale scale is the scale property.
val translate : translate_value -> declarationtranslate v is the translate property.
type filter = | NoneNo filter
*)| Blur of lengthblur(px)
*)| Brightness of numberbrightness(%)
*)| Contrast of numbercontrast(%)
*)| Drop_shadow of shadowdrop-shadow(...)
*)| Grayscale of numbergrayscale(%)
*)| Hue_rotate of anglehue-rotate(deg)
*)| Invert of numberinvert(%)
*)| Opacity of numberopacity(%)
*)| Saturate of numbersaturate(%)
*)| Sepia of numbersepia(%)
*)| Url of stringurl(...)
*)| List of filter listMultiple filters
*)| Var of filter varCustom filter variable
*)CSS filter values
val filter : filter -> declarationfilter values is the filter property.
val backdrop_filter : filter -> declarationbackdrop_filter values is the backdrop-filter property.
CSS clip property values (deprecated, but needed for sr-only).
type clip_path = | Clip_path_none| Clip_path_url of string| Clip_path_inset of length * length option * length option * length optioninset(top, right?, bottom?, left?) - supports 1-4 values
*)| Clip_path_circle of lengthCircle with radius
*)| Clip_path_ellipse of length * lengthEllipse with rx, ry
*)| Clip_path_polygon of (length * length) list| Clip_path_path of stringSVG path data
*)CSS clip-path property values for clipping regions.
val clip : clip -> declarationclip clip is the clip property (deprecated).
val clip_path : clip_path -> declarationclip_path path is the clip-path property.
val mask : string -> declarationmask mask is the mask property.
val mix_blend_mode : blend_mode -> declarationmix_blend_mode mode is the mix-blend-mode property.
val background_blend_mode : blend_mode -> declarationbackground_blend_mode values is the background-blend-mode property.
Properties that affect user interaction with elements including cursor appearance, user selection behavior, and pointer events.
type cursor = | Auto| Default| None| Help| Pointer| Progress| Wait| Cell| Crosshair| Text| Vertical_text| Alias| Copy| Move| No_drop| Not_allowed| Grab| Grabbing| E_resize| N_resize| Ne_resize| Nw_resize| S_resize| Se_resize| Sw_resize| W_resize| Ew_resize| Ns_resize| Nesw_resize| Nwse_resize| Col_resize| Row_resize| All_scroll| Zoom_in| Zoom_out| Url of string * (float * float) option * cursor| InheritCSS cursor values.
val cursor : cursor -> declarationcursor cursor is the cursor property.
val pointer_events : pointer_events -> declarationpointer_events events is the pointer-events property.
val user_select : user_select -> declarationuser_select select is the user-select property.
val webkit_user_select : user_select -> declarationwebkit_user_select select is the -webkit-user-select property.
val resize : resize -> declarationresize resize is the resize property.
val print_color_adjust : print_color_adjust -> declarationprint_color_adjust v is the print-color-adjust property.
val background_origin : background_box -> declarationbackground_origin v is the background-origin property.
val background_clip : background_box -> declarationbackground_clip v is the background-clip property.
CSS container queries and containment features for component-based responsive design and performance optimization through layout isolation.
aspect_ratio ratio is the aspect-ratio property.
val container_type : container_type -> declarationcontainer_type type_ is the container-type property for container queries.
val container_name : string -> declarationcontainer_name name is the container-name property.
CSS contain values
val contain : contain -> declarationcontain contain is the contain property.
Specialized functionality for advanced CSS features and legacy support.
Vendor-prefixed properties for browser compatibility and legacy support. These are implementation-specific extensions that may be needed for older browsers.
type webkit_appearance = | NoneNo appearance styling
*)| AutoDefault browser styling
*)| ButtonButton appearance
*)| TextfieldText field appearance
*)| MenulistSelect/dropdown appearance
*)| ListboxList box appearance
*)| CheckboxCheckbox appearance
*)| RadioRadio button appearance
*)| InheritInherit from parent
*)CSS -webkit-appearance values.
CSS -webkit-font-smoothing values.
val webkit_appearance : webkit_appearance -> declarationwebkit_appearance app is the -webkit-appearance property.
val webkit_font_smoothing : webkit_font_smoothing -> declarationwebkit_font_smoothing smoothing is the -webkit-font-smoothing property.
val moz_osx_font_smoothing : moz_osx_font_smoothing -> declarationmoz_osx_font_smoothing smoothing is the -moz-osx-font-smoothing property.
val webkit_tap_highlight_color : color -> declarationwebkit_tap_highlight_color color is the -webkit-tap-highlight-color property.
val webkit_text_decoration : text_decoration -> declarationwebkit_text_decoration decoration is the WebKit-only -webkit-text-decoration property.
val webkit_text_decoration_color : color -> declarationwebkit_text_decoration_color color is the WebKit-only -webkit-text-decoration-color property.
val webkit_line_clamp : webkit_line_clamp -> declarationwebkit_line_clamp clamp is the WebKit-only -webkit-line-clamp property.
val webkit_box_orient : webkit_box_orient -> declarationwebkit_box_orient orient is the WebKit-only -webkit-box-orient property.
val webkit_hyphens : hyphens -> declarationwebkit_hyphens hyphens is the WebKit-only -webkit-hyphens property.
val webkit_text_size_adjust : text_size_adjust -> declarationwebkit_text_size_adjust adjust is the WebKit-only -webkit-text-size-adjust property.
Specialized CSS properties organized by their functional purpose.
Properties for styling HTML lists and tables.
val list_style_type : list_style_type -> declarationlist_style_type lst is the list-style-type property.
val list_style_image : list_style_image -> declarationlist_style_image img is the list-style-image property.
val table_layout : table_layout -> declarationtable_layout value is the table-layout property.
val vertical_align : vertical_align -> declarationvertical_align value is the vertical-align property.
val list_style : string -> declarationlist_style value is the list-style shorthand property.
val border_spacing : length -> declarationborder_spacing value is the border-spacing property.
Properties specific to SVG rendering and styling.
val fill : svg_paint -> declarationfill paint is the SVG fill property.
val stroke : svg_paint -> declarationstroke paint is the SVG stroke property.
val stroke_width : length -> declarationstroke_width width is the SVG stroke-width property.
Properties for scroll behavior and touch interaction.
CSS scroll-snap-strictness values
CSS scroll-snap axis values
type scroll_snap_type = | Axis of scroll_snap_axis| Axis_with_strictness of scroll_snap_axis * scroll_snap_strictness| Inherit| Var of scroll_snap_type varCSS scroll-snap-type values
val touch_action : touch_action -> declarationtouch_action action is the touch-action property.
val scroll_snap_type : scroll_snap_type -> declarationscroll_snap_type type_ is the scroll-snap-type property.
val scroll_snap_align : scroll_snap_align -> declarationscroll_snap_align align is the scroll-snap-align property.
val scroll_snap_stop : scroll_snap_stop -> declarationscroll_snap_stop stop is the scroll-snap-stop property.
val scroll_behavior : scroll_behavior -> declarationscroll_behavior behavior is the scroll-behavior property for smooth scrolling.
val scroll_margin : length -> declarationscroll_margin margin is the scroll-margin property.
val scroll_margin_top : length -> declarationscroll_margin_top margin is the scroll-margin-top property.
val scroll_margin_right : length -> declarationscroll_margin_right margin is the scroll-margin-right property.
val scroll_margin_bottom : length -> declarationscroll_margin_bottom margin is the scroll-margin-bottom property.
val scroll_margin_left : length -> declarationscroll_margin_left margin is the scroll-margin-left property.
val scroll_padding : length -> declarationscroll_padding padding is the scroll-padding property.
val scroll_padding_top : length -> declarationscroll_padding_top padding is the scroll-padding-top property.
val scroll_padding_right : length -> declarationscroll_padding_right padding is the scroll-padding-right property.
val scroll_padding_bottom : length -> declarationscroll_padding_bottom padding is the scroll-padding-bottom property.
val scroll_padding_left : length -> declarationscroll_padding_left padding is the scroll-padding-left property.
val overscroll_behavior : overscroll_behavior -> declarationoverscroll_behavior behavior is the overscroll-behavior property.
val overscroll_behavior_x : overscroll_behavior -> declarationoverscroll_behavior_x behavior is the overscroll-behavior-x property.
val overscroll_behavior_y : overscroll_behavior -> declarationoverscroll_behavior_y behavior is the overscroll-behavior-y property.
val accent_color : color -> declarationaccent_color color is the accent-color property for form controls.
val caret_color : color -> declarationcaret_color color is the caret-color property for the text input cursor.
Other properties that don't fit into specific categories.
val forced_color_adjust : forced_color_adjust -> declarationforced_color_adjust adjust is the forced-color-adjust property.
val appearance : appearance -> declarationappearance app is the appearance property.
val tab_size : int -> declarationtab_size size is the tab-size property.
val font_variation_settings : font_variation_settings -> declarationfont_variation_settings settings is the font-variation-settings property.
Type-safe CSS custom properties (CSS variables) with GADT-based type checking.
type _ kind = | Length : length kind| Color : color kind| Rgb : rgb kind| Int : int kind| Float : float kind| Percentage : percentage kind| Number_percentage : number_percentage kind| String : string kind| Duration : duration kind| Aspect_ratio : aspect_ratio kind| Border_style : border_style kind| Outline_style : outline_style kind| Border : border kind| Font_weight : font_weight kind| Line_height : line_height kind| Font_family : font_family kind| Font_feature_settings : font_feature_settings kind| Font_variation_settings : font_variation_settings kind| Font_variant_numeric : font_variant_numeric kind| Font_variant_numeric_token : font_variant_numeric_token kind| Blend_mode : blend_mode kind| Scroll_snap_strictness : scroll_snap_strictness kind| Angle : angle kind| Shadow : shadow kind| Box_shadow : shadow kind| Content : content kind| Gradient_stop : gradient_stop kind| Gradient_direction : gradient_direction kind| Animation : animation kind| Timing_function : timing_function kind| Transform : transform kindValue kind GADT for typed custom properties
meta () is an injection/projection pair for metadata. The injection function converts a value to metadata, the projection function attempts to extract the value back.
val var_ref :
?fallback:'a fallback ->
?default:'a ->
?layer:string ->
?meta:meta ->
string ->
'a varvar_ref ?fallback ?default ?layer ?meta name is a CSS variable reference. This is primarily for the CSS parser to create var() references.
name is the variable name (without the -- prefix)fallback is used inside var(--name, fallback) in CSS outputdefault is the resolved value when mode is Inlinelayer is an optional CSS layer namemeta is optional metadata.@property Supporttype 'a syntax = | Length : length syntax| Color : color syntax| Number : float syntax| Integer : int syntax| Percentage : percentage syntax| Length_percentage : length_percentage syntax| Angle : angle syntax| Time : duration syntax| Custom_ident : string syntax| String : string syntax| Url : string syntax| Image : string syntax| Transform_function : string syntax| Universal : string syntax| Or : 'a syntax * 'b syntax -> ('a, 'b) Either.t syntax| Plus : 'a syntax -> 'a list syntax| Hash : 'a syntax -> 'a list syntax| Question : 'a syntax -> 'a option syntax| Brackets : string -> string syntaxType-safe syntax descriptors for CSS @property rules.
property ~name syntax ?initial_value ?inherits () creates a @property rule for registering a custom CSS property with type-safe syntax and initial value.
Examples:
property ~name:"--my-color" Variables.Color ~initial_value:(hex "#ff0000") ()property ~name:"--my-size" Variables.Length ~initial_value:(Px 10.) ()See MDN @property.
val var :
?default:'a ->
?fallback:'a fallback ->
?layer:string ->
?meta:meta ->
string ->
'a kind ->
'a ->
declaration * 'a varvar ?default ?fallback ?layer name kind value returns a declaration and a variable handle.
name is the variable name without the -- prefixkind specifies the value type (Length, Color, Angle, Float, etc.)default specifies the value to use in inline mode instead of var() referencefallback is used inside var(--name, fallback) in CSS outputlayer is an optional CSS layer name where the variable should be placedExample:
let def_radius, radius_var = var "radius-md" Length (Rem 0.5) in
rule ~selector:".card" [ def_radius; border_radius (Var radius_var) ]The returned radius_var must be wrapped with Var when used in CSS properties. In variables mode, it emits "--radius-md: 0.5rem" and uses "var(--radius-md)". In inline mode, it uses "0.5rem" directly when the default equals the defined value.
val meta_of_declaration : declaration -> meta optionmeta_of_declaration decl extracts metadata from a declaration if it has any.
val custom_property : ?layer:string -> string -> string -> declarationcustom_property ?layer name value is a CSS custom property declaration.
For type-safe variable declarations and usage, prefer using the var API which provides compile-time checking and automatic variable management.
Example: custom_property "--primary-color" "#3b82f6"
See also var (type-safe CSS variable API).
val custom_declaration_name : declaration -> string optioncustom_declaration_name decl is the variable name if decl is a custom property declaration, None otherwise.
val custom_declaration_layer : declaration -> string optioncustom_declaration_layer decl is the declared layer for a custom property declaration if present (e.g., "theme" or "utilities"). It is None for non-custom declarations or when no layer metadata is attached.
CSS output generation and performance optimization tools.
Functions for converting CSS structures to string output.
to_string ?minify ?optimize ?mode ?newline stylesheet renders a complete stylesheet to CSS.
minify is true, the output will be compact (no unnecessary whitespace).optimize is true, rule-level optimizations are applied (deduplication, merging consecutive rules, combining identical rules).mode controls variable layer emission behavior.newline is true (default), adds a trailing newline for POSIX compliance.pp is to_string.
val pp_parse_error : parse_error -> stringpp_parse_error error formats a parse error as a string, including call stack if available.
val of_string : ?filename:string -> string -> (t, parse_error) resultof_string ?filename css parses a CSS string into a stylesheet. Returns Error error on invalid CSS. The optional filename parameter is used for error reporting (defaults to "<string>").
Tools for optimizing CSS output for performance and file size.
optimize stylesheet applies CSS optimizations to the stylesheet, including merging consecutive identical selectors and combining rules with identical properties. Preserves CSS cascade semantics.
val will_change : will_change -> declarationwill_change value is the will-change property for performance optimization.
val inline_style_of_declarations :
?optimize:bool ->
?minify:bool ->
?mode:mode ->
?newline:bool ->
declaration list ->
stringinline_style_of_declarations declarations converts a list of declarations to an inline style string.
pp_length ?always is the pretty printer for length values. When always is true, units are always included even for zero values.
val pp_font_weight : font_weight Pp.tpp_font_weight is the pretty printer for font-weight values.
val pp_gradient_direction : gradient_direction Pp.tpp_gradient_direction is the pretty printer for gradient directions.
val pp_font_style : font_style Pp.tpp_font_style is the pretty printer for font-style values.
val pp_text_align : text_align Pp.tpp_text_align is the pretty printer for text-align values.
val pp_text_decoration : text_decoration Pp.tpp_text_decoration is the pretty printer for text-decoration values.
val pp_text_transform : text_transform Pp.tpp_text_transform is the pretty printer for text-transform values.
val pp_border_style : border_style Pp.tpp_border_style is the pretty printer for border-style values.
val pp_scroll_snap_strictness : scroll_snap_strictness Pp.tpp_scroll_snap_strictness is the pretty printer for scroll-snap-strictness values.
val pp_flex_direction : flex_direction Pp.tpp_flex_direction is the pretty printer for flex-direction values.
val pp_align_items : align_items Pp.tpp_align_items is the pretty printer for align-items values.
val pp_justify_content : justify_content Pp.tpp_justify_content is the pretty printer for justify-content values.
module Pp : sig ... endPrinter