Styling Components

Tesserae encourages fluent, strongly-typed styling. Many components expose convenience APIs for text formatting and visual adjustments, and extension methods provide layout-related styling (spacing, sizing, alignment).

Text formatting

Components that implement ITextFormating can be styled using text size, weight, and alignment helpers:

Text formatting helpers are defined in ITextFormatingExtensions, including fluent shortcuts like .Tiny(), .Small(), .Large(), .Bold(), and .TextCenter().

You can also set explicit values:

Fonts

Tesserae draws with exactly two font stacks, and every rule that sets a font-family names one of them with no inline fallback list of its own:

Variable Used for From C#
--tss-sansserif-font-family everything but code Theme.Fonts.SansSerif
--tss-monospace-font-family code, paths, identifiers Theme.Fonts.Monospace

Both default to system fonts only — a webfont has to be served by whoever uses it, so the toolkit never names one. An app that ships a font puts it in front by overriding the variable:

:root {
    --tss-sansserif-font-family: "Plus Jakarta Sans", "Inter", sans-serif;
    --tss-monospace-font-family: "Monaspace Neon", ui-monospace, monospace;
}

Override either one on :root (or on any sub-tree) and the whole UI follows, form controls included — those do not inherit the document font, which is why setting font-family on body alone was never enough. In C#, reference the variables through Theme.Fonts rather than repeating the var(...) literal:

TextBlock("id: 7bWQhKzR").Style(s => s.fontFamily = Theme.Fonts.Monospace);

Layout-based styling

Spacing and sizing helpers are part of IComponentExtensions and map to Stack/Grid layout properties:

These helpers set margin, padding, width/height, and flex behavior when used inside stacks or grids.

Shorthand helpers

Tesserae provides short forms for common sizing and spacing APIs:

Short forms include: P, PT, PB, PL, PR, M, MT, MB, ML, MR, W, H, S, WS, HS. They accept either UnitSize or an int (pixels).

UnitSize basics

UnitSize represents CSS sizes and has fluent helpers for common units:

Available units include px(), percent(), fr(), vw(), and vh(), along with convenience helpers like UnitSize.Auto() and UnitSize.FitContent(). You can manually initialize complex units using a string, for example: new UnitSize("calc(100% - 32px)").

Direct DOM styling (advanced)

For cases where you need a custom inline style, you can access the rendered element and apply styles directly:

You can also use the fluent Style(...) helper:

Prefer Tesserae’s fluent APIs first; direct DOM styling is useful for one-off customization or for styles not yet covered by the helper methods.

© 2026 Curiosity. All rights reserved.