---
url: /api/formats/scope/src.md
---
[pantoken-root](../../../index.md) / scope

# scope

Beta

`@pantoken/scope` — run several pantoken themes and color schemes in one document.

Pantoken's CSS keys themes to a `data-pantoken-theme` attribute that matches *any* element, not
just `:root`, so theming is a property of a subtree rather than of the page. This package is the
runtime half of that contract:

* [resolveScope](functions/resolveScope.md) walks up from an element to find the theme, scheme, and color in effect —
  the auto-detection half.
* [createScope](functions/createScope.md) declares a scope explicitly, with its own persisted state and its own frame
  message channel — the manual-configuration half that stops two instances colliding.
* [ensureProperties](functions/ensureProperties.md) injects the document-global `@property` registrations once, however
  many instances ask for them.

Node-free by design: this ships to the browser.

## Interfaces

* [ScopeConfig](interfaces/ScopeConfig.md)
* [ResolvedScope](interfaces/ResolvedScope.md)
* [ScopeMessage](interfaces/ScopeMessage.md)
* [CreateScopeOptions](interfaces/CreateScopeOptions.md)
* [PantokenScope](interfaces/PantokenScope.md)
* [ConnectScopeOptions](interfaces/ConnectScopeOptions.md)

## Type Aliases

* [Scheme](type-aliases/Scheme.md)

## Variables

* [DEFAULT\_INSTANCE](variables/DEFAULT_INSTANCE.md)
* [INSTANCE\_ATTR](variables/INSTANCE_ATTR.md)
* [SCOPE\_ATTRS](variables/SCOPE_ATTRS.md)

## Functions

* [ensureProperties](functions/ensureProperties.md)
* [hasProperties](functions/hasProperties.md)
* [observeScope](functions/observeScope.md)
* [resolveScope](functions/resolveScope.md)
* [resolveInstance](functions/resolveInstance.md)
* [resolveScheme](functions/resolveScheme.md)
* [getScope](functions/getScope.md)
* [createScope](functions/createScope.md)
* [connectScope](functions/connectScope.md)
* [isScheme](functions/isScheme.md)

## References

### BOUNDARY\_ATTR

Re-exports [BOUNDARY\_ATTR](../../css/src/variables/BOUNDARY_ATTR.md)

***

### BOUNDARY\_CLASS

Re-exports [BOUNDARY\_CLASS](../../css/src/variables/BOUNDARY_CLASS.md)

***

### COLOR\_ATTR

Re-exports [COLOR\_ATTR](../../css/src/variables/COLOR_ATTR.md)

***

### SCHEME\_ATTR

Re-exports [SCHEME\_ATTR](../../css/src/variables/SCHEME_ATTR.md)

***

### THEME\_ATTR

Re-exports [THEME\_ATTR](../../css/src/variables/THEME_ATTR.md)

***

### colorClass

Re-exports [colorClass](../../css/src/variables/colorClass.md)

***

### schemeClass

Re-exports [schemeClass](../../css/src/variables/schemeClass.md)

***

### themeClass

Re-exports [themeClass](../../css/src/variables/themeClass.md)
