API Reference

The customer-facing surface of MonorailCss. Public types you'll touch when configuring or extending the engine.

Class MonorailCss.CssFramework #

Main entry point for the MonorailCss framework. Processes Tailwind CSS utility classes and generates optimized CSS output.

Constructors 2
public CssFramework()
Initializes a new instance of the CssFramework class. Initializes a new instance of the CssFramework with default configuration.
public CssFramework(CssFrameworkSettings settings)
Initializes a new instance of the CssFramework class. Initializes a new instance of the CssFramework with custom settings.
Properties 1
public CssFrameworkSettings Settings { get; }
Gets the settings this framework was constructed from, after any constructor-time adjustments (e.g. ProseCustomization applied to the theme). Use this when you need to layer additional configuration on top — for example, the discovery library merges CSS-derived theme tokens, custom utilities, and custom variants into a fresh framework built from these settings.
Methods 10
public void AddUtility(IUtility utility)
Adds a custom utility to the framework at runtime. The utility will be registered with proper priority ordering.
public void AddUtilities(IEnumerable utilities)
Adds multiple custom utilities to the framework at runtime. The utilities will be registered with proper priority ordering.
public void AddVariant(IVariant variant, bool overwrite = false)
Adds a custom variant to the framework at runtime.
public string Process(string classString)
Processes a string of CSS classes and returns the generated CSS.
public string Process(IEnumerable candidates)
Processes a collection of CSS class names and returns the generated CSS.
public bool TryValidateCandidate(string token)
Tests whether a single token would parse as a valid utility candidate. Use as a fast validator when filtering arbitrary strings (e.g. extracted from IL user-string heaps) before feeding them to Process. Never throws — returns false for null, empty, or unparseable input.
public IReadOnlyCollection GetStaticUtilityNames()
Gets the names of all registered static utilities (e.g. "flex", "block", "hidden"). Used by the discovery library to build a fast pre-filter that distinguishes candidate strings from natural-language strings before invoking the full parser.
public IReadOnlyCollection GetFunctionalUtilityPrefixes()
Gets the roots of all registered functional utilities (e.g. "bg", "text", "p", "m"). Used by the discovery library to build a fast pre-filter that distinguishes candidate strings from natural-language strings before invoking the full parser.
public string ProcessMultiple(string[] classStrings)
Processes multiple CSS class strings and returns the combined generated CSS.
public string CompileUtilityClass(string className)
Compiles a single utility class and returns its CSS declarations. This applies modifier processing (opacity, negative values, !important, variable fallbacks). Useful for documentation and debugging purposes.
Record MonorailCss.CssFrameworkSettings #

Represents configuration settings for the CSS framework, including theme customization, variant handling, and other framework-level options.

Constructors 1
public CssFrameworkSettings()
Initializes a new instance of the CssFrameworkSettings class.
Properties 10
public Theme Theme { get; set; }
Gets the theme configuration used by the framework, including design tokens and scales.
public ImmutableHashSet Variants { get; set; }
Gets the set of enabled variant identifiers (e.g., responsive breakpoints, state variants).
public bool Important { get; set; }
Gets a value indicating whether generated utilities should be emitted with the !important flag.
public bool IncludePreflight { get; set; }
Gets a value indicating whether the framework's base (preflight) styles should be included.
public ImmutableDictionary Applies { get; set; }
Gets a map of custom apply rules where the key is a CSS selector (or alias) and the value is a space-separated list of utility class names to apply. Each utility may carry variants such as hover: or md:. Raw CSS declarations are supported (mirroring Tailwind's @apply, which accepts utilities only); use arbitrary-value utilities like bg-[color-mix(in_oklab,red,blue)] to emit literal values.
public ProseCustomization ProseCustomization { get; set; }
Gets the optional customization for prose/typographic styles.
public ImmutableList CustomUtilities { get; set; }
Gets a list of custom utility definitions to be registered with the framework. These are typically parsed from @utility blocks in CSS source files.
public ImmutableList CustomVariants { get; set; }
Gets a list of custom variant definitions to be registered with the framework. These are typically parsed from @custom-variant directives in CSS source files. Each variant definition includes a name and selector pattern (e.g., "scrollbar" with "&::-webkit-scrollbar").
public ColorEmissionMode ColorEmission { get; set; }
Gets the mode that controls which --color-* CSS variables are emitted in the generated output. Defaults to UsedPalettes so that dynamic class names (e.g. bg-sky-700 rendered after build) resolve correctly.
public ImmutableDictionary Keyframes { get; set; }
Gets a map of animation name → keyframes body, populated from @keyframes blocks declared inside any @theme flavor (regular, inline, static, static inline). Used by the CSS generator to emit a top-level @keyframes rule whenever the matching --animate-{name} theme variable ends up in the output; user entries override the built-in defaults (spin, ping, pulse, bounce) on name collision.
Enum MonorailCss.ColorEmissionMode #

Controls which --color-* theme variables are emitted in the generated CSS.

Values 3
public static const ColorEmissionMode Used
Only emit color variables actually referenced by generated CSS.
public static const ColorEmissionMode UsedPalettes
For every used --color-{palette}-{shade}, also emit every other shade in that palette. Singletons such as --color-black are unaffected.
public static const ColorEmissionMode All
Emit every --color-* variable defined in the theme.
Record MonorailCss.CustomVariantDefinition #

Represents a custom variant definition for extending the framework's built-in variants.

Properties 3
public string Name { get; set; }
Gets the variant name (e.g., "scrollbar", "scrollbar-track").
public string Selector { get; set; }
Gets the selector pattern, typically using & for parent reference. Example: "&::-webkit-scrollbar" or "&::-webkit-scrollbar-track".
public int Weight { get; set; }
Gets the weight for ordering. Lower values appear earlier in the output. Defaults to 490 (just before built-in pseudo-elements at 500+).