# TreeBuilder

`import { TreeBuilder } from "destack:tree";`

Contextual builder for tree literals.

A node type opts into tree literals by implementing `TreeBuilder`.
The compiler resolves the builder from the literal's expected type, or
from the profile's configured default, checks lowercase tags against
`Tags`, and builds elements and fragments through the statics below.

```ds title="TreeBuilder"
export newtype interface TreeBuilder {
    Tags = {};
    static element<const Tag: keyof this.Tags, Children: (...unknown[],)>(tag: Tag, attributes: this.Tags[Tag], children: Children): this;
    static fragment<Children: (...unknown[],)>(children: Children): this;
}
```

[language/library/src/tree/builder.ds:8:21](https://github.com/destack-sh/destack/blob/main/language/library/src/tree/builder.ds#L8-L21)

## Members

### `Tags = {}`

The lowercase tags this builder accepts, with their attribute rows.

### `static element<const Tag: keyof this.Tags, Children: (...unknown[],)>(tag: Tag, attributes: this.Tags[Tag], children: Children): this`

Build one element from its tag, attributes, and children.

### `static fragment<Children: (...unknown[],)>(children: Children): this`

Build one fragment from its children.
