Skip to content

<rc-class>

Named reusable style class. Content nodes reference it via their rc-class attribute to inherit its styles, centralising typography and colour definitions in one place.

Attributes

AttributeDefaultConstraintExampleDescription
nameStringprimary-buttonIdentifier used to reference this class from content elements.
background-colorCSS color value#1a1a2eBackground colour applied to matching nodes.
colorCSS color value#ffffffText colour applied to matching nodes.
font-familyStringInter, sans-serifFont family, comma-separated with a generic fallback (e.g. Inter, sans-serif).
font-sizePixel value16pxFont size in pixels.
font-stylenormal | italic | obliqueitalicCSS font-style keyword.
font-weight100900700Numeric font weight.
letter-spacingpx or em, negatives allowed1pxSpace between characters.
line-heightpx or percentage24pxLine height in pixels or as a percentage of the font size.
text-decorationnone | underline | overline | line-throughunderlineCSS text-decoration keyword.
text-transformcapitalize | uppercase | lowercaseuppercaseCSS text-transform keyword.
srcStringhttps://cdn.example.com/image.jpgDefault image source URL for image-type nodes that reference this class.
widthPixel value300pxDefault width for nodes that reference this class.

Children

None.

Parents

JSON

json
{
  "tagName": "rc-class",
  "attributes": {
    "name": "primary-button",
    "background-color": "#1a1a2e",
    "color": "#ffffff",
    "font-size": "16px",
    "font-weight": "700"
  }
}

XML

xml
<rc-class name="primary-button" background-color="#1a1a2e" color="#ffffff" font-size="16px" font-weight="700"></rc-class>

Usage

Building

Templates can be built using factory functions from @rule/rcml, or the JSON structure above can be generated directly by an AI model — pass rcmlSpec as context when prompting.

typescript
import { createClassElement } from '@rule/rcml';

createClassElement({
  attrs: {
    name: 'primary-button',
    'background-color': '#1a1a2e',
    color: '#ffffff',
    'font-size': '16px',
    'font-weight': '700',
  },
})

Referencing from body elements

Body elements apply a class by setting their rc-class attribute to the class name. Multiple classes are space-separated.

The rc-class attribute is supported by: <rc-text>, <rc-heading>, <rc-button>, and <rc-logo>.

json
{
  "tagName": "rc-class",
  "attributes": { "name": "cta", "background-color": "#1a1a2e", "color": "#ffffff", "font-weight": "700" }
}
json
{
  "tagName": "rc-button",
  "attributes": { "rc-class": "cta", "href": "https://example.com" },
  "children": [...]
}
xml
<!-- Define in head -->
<rc-class name="cta" background-color="#1a1a2e" color="#ffffff" font-weight="700"></rc-class>

<!-- Reference in body -->
<rc-button rc-class="cta" href="https://example.com">Shop now</rc-button>

<!-- Multiple classes, space-separated -->
<rc-button rc-class="cta rounded" href="https://example.com">Shop now</rc-button>

API Reference