---
title: "ThemeResult"
description: "The object [createTheme](https://pitlane.tools/package/theme/function/createTheme.md) returns: the typed token accessor, the `raw` resolver, the `<Theme />` component, and the two derivation methods."
url: "https://pitlane.tools/package/theme/interface/ThemeResult"
---

# ThemeResult

```ts
import type { ThemeResult } from "@pitlane/theme";
```

The object [createTheme](https://pitlane.tools/package/theme/function/createTheme.md) returns: the typed token accessor, the `raw` resolver, the `<Theme />` component, and the two derivation methods.

## Type Parameters

### T

`T`

## Properties

### Theme

```ts
readonly Theme: ThemeComponent<T>;
```

The component that installs the custom properties.

---

### token

```ts
readonly token: TokenTree<T>;
```

A typed mirror of the token tree whose leaves are branded `var()` reference strings. A `s.scale()` leaf is callable.

## Methods

### extend()

```ts
extend<schema, tokens>(patch): ThemeResult<Merged<T, {
  schema: schema;
  tokens: tokens;
}>>;
```

Deep-merges a patch onto this theme and returns a new one. A leaf replaces wholesale; every other node recurses.

The callback form receives this theme's accessor, so a patch can reference what it extends.

#### Type Parameters

##### schema

`schema` _extends_ `object`

##### tokens

`tokens` _extends_ `object`

#### Parameters

##### patch

| `ExtendPatch`\<`T`, `schema`, `tokens`> | ((`base`: [`TokenTree`](https://pitlane.tools/package/theme/type/TokenTree.md)\<`T`>) => `ExtendPatch`\<`T`, `schema`, `tokens`>)

The tokens and schema to merge, or a callback returning them: a [ThemePatch](https://pitlane.tools/package/theme/interface/ThemePatch.md) whose `schema` and `tokens` types are kept exactly. `schema` is optional when the patch only adds tokens to namespaces the theme already types. `modes` may override any token of the merged tree, including tokens the patch itself does not declare.

#### Returns

`ThemeResult`\<`Merged`\<`T`, { `schema`: `schema`; `tokens`: `tokens`; }>>

A new theme

#### Throws

ThemeError when the patch holds no `tokens` group

---

### raw()

```ts
raw(ref): string;
```

Resolves a token reference to its concrete base value, following references to the end.

#### Parameters

##### ref

| [`AnyToken`](https://pitlane.tools/package/theme/type/AnyToken.md) | [`UntypedToken`](https://pitlane.tools/package/theme/type/UntypedToken.md)

A token reference minted by this theme

#### Returns

`string`

The serialized base value

#### Throws

ThemeError when the reference was not minted here

---

### select()

```ts
select<P>(projection): ThemeResult<P>;
```

Replaces this theme with a projection of it. The callback receives this theme's accessor; every value in the projection is a reference into it, and the new path decides the new custom property name, so a projection may also reshape and rename.

#### Type Parameters

##### P

`P` _extends_ [`ThemeInit`](https://pitlane.tools/package/theme/interface/ThemeInit.md)

#### Parameters

##### projection

(`base`: [`TokenTree`](https://pitlane.tools/package/theme/type/TokenTree.md)\<`T`>) => `P`

A callback returning the schema and tokens to keep

#### Returns

`ThemeResult`\<`P`>

A new theme

#### Throws

ThemeError when the projection holds no `tokens` group
