Tesserae

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:

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.

Referenced by

© 2026 Tesserae. All rights reserved.