# Attributes
Typed attributes on a template constructor, reactive expression blocks, and
the two-way bindings Elements installs on form controls.
Attributes go in `()` on the opening tag. Each attribute is `public` (the
default) or `private`. Optional attributes use `?`. Attributes can have
initializers that reference other attributes, and declaration order does not
matter. `private` attributes cannot be provided by callers, but they can be
mutated inside the template scope.
```html
{greeting}
```
Attributes are fully typed and integrated with the codebase's tooling: rename,
find-references, go-to-definition, and type checking work across templates and
TypeScript alike.
Attributes are reactive automatically, including across template boundaries:
```html
done: {tasks.filter(t => t.done).length}
```
Toggling the checkbox in `` updates the count in `` immediately.
**Attributes live on the root tag only.** An attribute list on a non-root element
(e.g. `
`) is invalid.
**A union inside an object default needs a cast.** The declared type does not
currently reach into an object literal used as a default, so a union field in
one is inferred as its widened type and rejected:
```html
```
Grouping template state into one object is the usual way to keep it mutable: a
handler can mutate an object's fields and the change is live, while reassigning
a plain attribute inside a handler is not (see Reactivity). The object is
therefore often the right shape, and the cast is the price until this is fixed.
## Expressions
`{ ... }` is a TypeScript expression. Allowed as element children and attribute
values.
```html