Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file preflight.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533(** Preflight and reset rules *)moduleCss=Cascade.CssopenCss(* Base element selectors *)letabbr=Selector.element"abbr"letbutton=Selector.element"button"letinput=Selector.element"input"letselect=Selector.element"select"letoptgroup=Selector.element"optgroup"letoption=Selector.element"option"(* Attribute selectors *)lettitle=Selector.attribute"title"Presenceletmultiple=Selector.attribute"multiple"Presenceletsize=Selector.attribute"size"Presencelettype_button=Selector.attribute"type"(Exact"button")lettype_reset=Selector.attribute"type"(Exact"reset")lettype_submit=Selector.attribute"type"(Exact"submit")lethidden=Selector.attribute"hidden"Presencelethidden_until_found=Selector.attribute"hidden"(Exact"until-found")(* Complex selectors *)letabbr_with_title=Selector.(abbr&&where[title])letselect_is_multiple_size=Selector.(select&&is_[multiple;size])letradiuslen=Radius{horizontal=[Lengthlen];vertical=None}letinput_button_types=Selector.(input&&where[type_button;type_reset;type_submit])lethidden_not_until_found=Selector.(hidden&&where[not[hidden_until_found]])(** Box model resets *)letbox_resets()=letopenSelectorin[rule~selector:(Selector.list[Selector.universal;AfterDouble;BeforeDouble;Backdrop])[box_sizingBorder_box;border~width:Zero~style:Solid();margin[Zero];padding[Zero];];rule~selector:File_selector_button[box_sizingBorder_box;border~width:Zero~style:Solid();margin[Zero];padding[Zero];];](* Font feature/variation settings variables Order (8, 10+) to come after
default-transition-* (8, 0-1) *)letfont_feature=Var.themeCss.Font_feature_settings"default-font-feature-settings"~order:(8,10)letfont_variation=Var.themeCss.Font_variation_settings"default-font-variation-settings"~order:(8,11)letmono_font_feature=Var.themeCss.Font_feature_settings"default-mono-font-feature-settings"~order:(8,12)letmono_font_variation=Var.themeCss.Font_variation_settings"default-mono-font-variation-settings"~order:(8,13)(** Helper for creating variable references in preflight context
This is ONLY safe to use in preflight.ml because: 1. Preflight runs in the
base layer, which comes AFTER theme layer 2. We're creating "optional
customization hooks" - variables that are intentionally NOT declared
anywhere by default 3. This creates var(--name, fallback) CSS that always
uses the fallback unless users/plugins declare the variables themselves 4.
This enables theme customization without bloating the default CSS
Uses the proper Var.reference API with explicit fallback. *)letvar_ref(typea)(var:(a,[<`Theme|`Property_default|`Channel])Var.t)~(fallback:a):aCss.var=Var.reference_with_fallbackvarfallback(** HTML and body defaults *)letroot_resets~default_font_ref~font_feature_ref~font_variation_ref=letfallback_stack:font_family=List[Ui_sans_serif;System_ui;Sans_serif;Apple_color_emoji;Segoe_ui_emoji;Segoe_ui_symbol;Noto_color_emoji;]in(* Add fallback for theme-declared font variable *)letdefault_font_with_fallback=Css.with_fallbackdefault_font_reffallback_stackin(* Add fallback for optional customization hooks *)letfont_feature_with_fallback:Css.font_feature_settingsCss.var=Css.with_fallbackfont_feature_ref(Css.Normal:Css.font_feature_settings)inletfont_variation_with_fallback:Css.font_variation_settingsCss.var=Css.with_fallbackfont_variation_ref(Css.Normal:Css.font_variation_settings)in[rule~selector:Selector.(list[element"html";host()])[webkit_text_size_adjust(Pct100.);tab_size4;line_height(Num1.5);font_family(Css.Vardefault_font_with_fallback);font_feature_settings(Varfont_feature_with_fallback);font_variation_settings(Varfont_variation_with_fallback);webkit_tap_highlight_colorTransparent;];](** Structural elements *)letstructural_resets()=[rule~selector:(Selector.element"hr")[heightZero;colorInherit;border_top_width(Px1.)];rule~selector:abbr_with_title[webkit_text_decoration(Shorthand{lines=[Underline];style=SomeDotted;color=None;thickness=None;});text_decoration(Shorthand{lines=[Underline];style=SomeDotted;color=None;thickness=None;});];](** Typography resets *)lettypography_resets()=[rule~selector:Selector.(list[Selector.element"h1";Selector.element"h2";Selector.element"h3";Selector.element"h4";Selector.element"h5";Selector.element"h6";])[font_sizeInherit;font_weightInherit];rule~selector:(Selector.element"a")[colorInherit;webkit_text_decorationInherit;text_decorationInherit];rule~selector:Selector.(list[Selector.element"b";Selector.element"strong"])[font_weightBolder];](** Code and monospace resets *)letcode_resets~default_mono_ref~mono_font_feature_ref~mono_font_variation_ref=[rule~selector:Selector.(list[element"code";element"kbd";element"samp";element"pre"])(letfallback_stack:font_family=List[Ui_monospace;SFMono_regular;Menlo;Monaco;Consolas;Liberation_mono;Courier_new;Monospace;]in(* Add fallback for theme-declared font variable *)letdefault_mono_with_fallback=Css.with_fallbackdefault_mono_reffallback_stackin(* Add fallback for optional customization hooks *)letfont_feature_with_fallback:Css.font_feature_settingsCss.var=Css.with_fallbackmono_font_feature_ref(Css.Normal:Css.font_feature_settings)inletfont_variation_with_fallback:Css.font_variation_settingsCss.var=Css.with_fallbackmono_font_variation_ref(Css.Normal:Css.font_variation_settings)in[font_family(Css.Vardefault_mono_with_fallback);font_feature_settings(Varfont_feature_with_fallback);font_variation_settings(Varfont_variation_with_fallback);font_size(Em1.0);]);](** Text-level semantics *)lettext_level_resets()=[rule~selector:(Selector.element"small")[font_size(Pct80.0)];rule~selector:Selector.(list[Selector.element"sub";Selector.element"sup"])[vertical_alignBaseline;font_size(Pct75.0);line_height(Num0.);positionRelative;];rule~selector:(Selector.element"sub")[bottom(Em(-0.25))];rule~selector:(Selector.element"sup")[top(Em(-0.5))];](** Table resets *)lettable_resets()=[rule~selector:(Selector.element"table")[text_indent(Indent{length=LengthZero;hanging=false;each_line=false});border_colorInherit;border_collapseCollapse;];](** Interactive elements *)letinteractive_resets()=[rule~selector:Moz_focusring[outline(Shorthand{width=None;style=SomeAuto;color=None})];rule~selector:(Selector.element"progress")[vertical_alignBaseline];rule~selector:(Selector.element"summary")[displayList_item];](** List resets *)letlist_resets()=[rule~selector:Selector.(list[Selector.element"ol";Selector.element"ul";Selector.element"menu";])[list_style(Shorthand{type_=SomeNone;position=None;image=SomeNone});];](** Media resets *)letmedia_resets()=[rule~selector:Selector.(list[Selector.element"img";Selector.element"svg";Selector.element"video";Selector.element"canvas";Selector.element"audio";Selector.element"iframe";Selector.element"embed";Selector.element"object";])[vertical_alignMiddle;displayBlock];rule~selector:Selector.(list[Selector.element"img";Selector.element"video"])[max_width(Pct100.0);heightAuto];](** Form control resets *)letform_control_resets()=[rule~selector:Selector.(list[Selector.element"button";Selector.element"input";Selector.element"select";Selector.element"optgroup";Selector.element"textarea";])[fontInherit;font_feature_settingsInherit;font_variation_settingsInherit;letter_spacingInherit;colorInherit;opacity(Opacity_number1.0);background_color(hex"#0000");border_radius(radiusZero);];rule~selector:File_selector_button[fontInherit;font_feature_settingsInherit;font_variation_settingsInherit;letter_spacingInherit;colorInherit;opacity(Opacity_number1.0);background_color(hex"#0000");border_radius(radiusZero);];](** Select and option resets *)letselect_resets()=[rule~selector:Selector.(where[select_is_multiple_size]++optgroup)[font_weightBolder];rule~selector:Selector.(where[select_is_multiple_size]++optgroup++option)[padding_inline_start(Px20.)];rule~selector:File_selector_button[margin_inline_end(Px4.)];](** Form placeholder and textarea resets *)letform_misc_resets()=[rule~selector:Placeholder[opacity(Opacity_number1.0)];rule~selector:(Selector.element"textarea")[resizeVertical];](** Webkit-specific form resets. When [~forms:true], omits rules that the forms
plugin provides (display:inline-flex and fields-wrapper padding) to avoid
duplicates. *)letwebkit_form_resets?(forms=false)()=letbase_rules=[rule~selector:Webkit_search_decoration[webkit_appearanceNone];rule~selector:Webkit_date_and_time_value[min_height(Lh1.0);text_alignInherit];]in(* Tailwind v4's [\@tailwindcss/forms] with [strategy: 'class'] does not touch
global webkit datetime pseudo-elements, so preflight always emits these
(independent of the [~forms] flag). *)let_=formsinletforms_provided_rules=[rule~selector:Webkit_datetime_edit[displayInline_flex];rule~selector:Webkit_datetime_edit_fields_wrapper[padding[Zero]];]inletpadding_block_rules=[rule~selector:Webkit_datetime_edit[padding_block[Zero]];rule~selector:Webkit_datetime_edit_year_field[padding_block[Zero]];rule~selector:Webkit_datetime_edit_month_field[padding_block[Zero]];rule~selector:Webkit_datetime_edit_day_field[padding_block[Zero]];rule~selector:Webkit_datetime_edit_hour_field[padding_block[Zero]];rule~selector:Webkit_datetime_edit_minute_field[padding_block[Zero]];rule~selector:Webkit_datetime_edit_second_field[padding_block[Zero]];rule~selector:Webkit_datetime_edit_millisecond_field[padding_block[Zero]];rule~selector:Webkit_datetime_edit_meridiem_field[padding_block[Zero]];rule~selector:Webkit_calendar_picker_indicator[line_height(Num1.)];]inbase_rules@forms_provided_rules@padding_block_rules(** Firefox-specific form resets *)letfirefox_form_resets()=[rule~selector:Moz_ui_invalid[box_shadowNone]](** Buttons need specific styles *)letbutton_specific_resets()=[(* Complex selector - temporary workaround *)rule~selector:Selector.(list[button;input_button_types])[appearanceButton];](** Button appearance resets *)letbutton_resets()=[rule~selector:File_selector_button[appearanceButton];rule~selector:Webkit_inner_spin_button[heightAuto];rule~selector:Webkit_outer_spin_button[heightAuto];](** Hidden elements *)lethidden_resets()=[rule~selector:hidden_not_until_found[important(displayNone)]]letfont_family_refthemefallback_stack=let_,ref=Var.bindingthemefallback_stackinrefletdefault_font_stack:font_family=List[Ui_sans_serif;System_ui;Sans_serif;Apple_color_emoji;Segoe_ui_emoji;Segoe_ui_symbol;Noto_color_emoji;]letdefault_mono_stack:font_family=List[Ui_monospace;SFMono_regular;Menlo;Monaco;Consolas;Liberation_mono;Courier_new;Monospace;](* Get default sans-serif font family reference *)letdefault_font_family_ref()=font_family_refTypography.default_font_family_vardefault_font_stack(* Get default monospace font family reference *)letdefault_mono_family_ref()=font_family_refTypography.default_mono_font_family_vardefault_mono_stack(* Get all font customization variable references *)letfont_customization_refs()=letfont_feature_ref:Css.font_feature_settingsCss.var=var_reffont_feature~fallback:(Css.Normal:Css.font_feature_settings)inletfont_variation_ref:Css.font_variation_settingsCss.var=var_reffont_variation~fallback:(Css.Normal:Css.font_variation_settings)inletmono_font_feature_ref:Css.font_feature_settingsCss.var=var_refmono_font_feature~fallback:(Css.Normal:Css.font_feature_settings)inletmono_font_variation_ref:Css.font_variation_settingsCss.var=var_refmono_font_variation~fallback:(Css.Normal:Css.font_variation_settings)in(font_feature_ref,font_variation_ref,mono_font_feature_ref,mono_font_variation_ref)letstylesheet?placeholder_supports?(forms=false)()=letdefault_font_ref=default_font_family_ref()inletdefault_mono_ref=default_mono_family_ref()inlet(font_feature_ref,font_variation_ref,mono_font_feature_ref,mono_font_variation_ref)=font_customization_refs()inletbase_rules=List.concat[box_resets();root_resets~default_font_ref~font_feature_ref~font_variation_ref;structural_resets();typography_resets();code_resets~default_mono_ref~mono_font_feature_ref~mono_font_variation_ref;text_level_resets();table_resets();interactive_resets();list_resets();media_resets();form_control_resets();select_resets();form_misc_resets();webkit_form_resets~forms();firefox_form_resets();button_specific_resets();button_resets();hidden_resets();]inmatchplaceholder_supportswith|None->Css.vbase_rules|Somesupports->(* Split the rules at placeholder and insert the @supports *)letrecsplit_after_placeholderacc=function|[]->(List.revacc,[])|h::t->(matchCss.statement_selectorhwith|SomeselwhenCss.Selector.to_stringsel="::placeholder"->(List.rev(h::acc),t)|_->split_after_placeholder(h::acc)t)inletbefore,after=split_after_placeholder[]base_rulesinCss.concat[Css.vbefore;supports;Css.vafter]