Services

TokensServiceInterface

v1.0.0

Design token access for CSS variables and request-level token overrides.

Access

$ctx->tokens()?->get('color.surface');

How To Use It

  • Use it when module output needs runtime-aware design tokens instead of hard-coded colors or spacing values.
  • Keep token writes scoped and intentional so request-level overrides do not silently drift away from the shared Meteorack theme.

Methods

public function get(string $key): ?string

Reads a design token value or null when the token is undefined.

public function all(): array

Returns the full active token map.

public function set(string $key, string $value): void

Overrides a token value for the active request.

Example

bootstrap.php
public function onSdkReady(SdkContext $ctx): void
{
    parent::onSdkReady($ctx);

    $ctx->tokens()?->set('color.surface', '#101418');
    $ctx->logger()->debug('reports.tokens_loaded', [
        'surface' => $ctx->tokens()?->get('color.surface'),
    ]);
}