@core/css

@core/css provides inline style fragments for the style slots exposed by @core/html. It is a mandatory Core/MothSource package, so every builder gets the same six constants and the same .mtf prelude contribution. It publishes through a directly contained @package.moth.

Choose the explanation level: Style helpers

Style helpers

@core/css gives you six ready-made inline style fragments for the style slots on @core/html helpers. Each fragment folds into the surrounding HTML string during compilation and adds no runtime code.

Using the fragments in .mtf files

.mtf files see the constants by bare name because both @core/html and @core/css supply the fixed template prelude:

[h1, center: A centred heading.]

The fragment fills the helper's style slot. The same constants are available under every builder, not only HTML projects.

Binding in .moth files

A .moth file needs an explicit dependency clause:

@core/css center, larger

The six exports

  • center produces text-align: center;
  • right produces text-align: right;
  • left produces text-align: left;
  • smaller produces font-size: smaller;
  • medium produces font-size: medium;
  • larger produces font-size: larger;

For the full export table and prelude rules see @core/css advanced.

@core/css provides compile-time inline CSS fragments for the style slots exposed by @core/html. It carries Core origin with MothSource backing. See Package origins and backing for origin and backing rules.

The compiler reads packages/core/css/@package.moth, and the common builder surface registers the root under every builder, including custom SDK builders. A project cannot replace the package or remove it from the .mtf prelude.

Exports

Every export is a compile-time #String. The value is one styled template fragment with a trailing semicolon:

Constant

CSS

center

text-align: center;

right

text-align: right;

left

text-align: left;

smaller

font-size: smaller;

medium

font-size: medium;

larger

font-size: larger;

Relationship to @core/html slots

Each fragment is written as an $in style: contribution. Template heads pass the constant by name, so the CSS lands in the style attribute exposed by the @core/html helper:

[h1, center: A centred heading.]

A .moth file binds constants before it builds or inserts a template:

@core/css center, larger

The fragments carry no runtime behaviour and need no runtime assets. Only compile-time constants enter the .mtf prelude. Functions, types and private constants require an explicit dependency clause in .moth files.

Prelude contribution

@core/css contributes all six constants to the fixed .mtf prelude. A public constant declared by the package enters that prelude even when another file in the package exports it. A re-export of another package's declaration does not. See HTML helpers and Template scope.

Related concepts