Services
TokensServiceInterface
v1.0.0Design 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.
Works Well With
Methods
public function get(string $key): ?stringReads a design token value or null when the token is undefined.
public function all(): arrayReturns the full active token map.
public function set(string $key, string $value): voidOverrides 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'),
]);
}