Skip to the content.

Attributes are key-value pairs that configure elements and provide metadata.

Syntax

Attribute syntax uses key-value pairs separated by semicolons and/or newlines:

(
    key1: value1;
    key2: value2
    key3: value3
)

Data Types

Attributes can have different data types that define what values they can contain and how they are validated. Chalk supports both built-in primitive data types and custom data types defined in your library.

Primitive Types

Examples

element(
    title: My Title
    count: 42
    enabled: true
    tags: javascript,react,frontend
    description: This supports **bold** and *italic* text
)

Custom Types

Libraries can define custom attribute types with validation:

const dateType = {
  identifier: 'date',
  validate: (value) => /^\d{4}-\d{2}-\d{2}$/.test(value)
};

Attribute Validation

Next Steps