> For the complete Mojo documentation index, see [llms.txt](/llms.txt).
> Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

# Mojo decorators

A Mojo decorator modifies or extends the behavior of a struct, function, or
other declaration at compile time. You place the decorator on the line
above the declaration it applies to, prefixed with `@`.

```mojo
@fieldwise_init
struct Point:
    var x: Float64
    var y: Float64
```

After the `@`, a decorator is followed by a name, with optional arguments
in parentheses. Each decorator goes on its own line. You can stack multiple
decorators on a single declaration:

```mojo
@fieldwise_init
@align(64)
struct CacheLine:
    var data: SIMD[DType.float32, 16]
```

Decorators apply bottom-up: the one closest to the declaration
is applied first.

:::note No custom decorators
Mojo doesn't support custom decorators. The decorators in this section
are built into the compiler.
:::

## Decorators

The following pages describe each built-in decorator with examples.

## Decorator targets

Not every decorator works on every declaration. This table shows
which decorators are valid on which targets.

| Decorator            | `struct` | `def` | method | `trait` | `comptime` | `var` | field |
|----------------------|----------|-------|--------|---------|------------|-------|-------|
| `@align`             | yes      |       |        |         |            |       |       |
| `@always_inline`     |          | yes   | yes    |         |            |       |       |
| `@compiler.register` | yes      |       |        |         |            |       |       |
| `@__copy_capture`    |          |       | yes    |         |            |       |       |
| `@deprecated`        | yes      | yes   | yes    | yes     | yes        |       |       |
| `@doc_hidden`        | yes      | yes   | yes    |         | yes        |       | yes   |
| `@explicit_destroy`  | yes      |       |        |         |            |       |       |
| `@export`            |          | yes   |        |         |            |       |       |
| `@fieldwise_init`    | yes      |       |        |         |            |       |       |
| `@implicit`          |          |       | yes    |         |            |       |       |
| `@no_inline`         |          | yes   | yes    |         |            |       |       |
| `@nonmaterializable` | yes      |       |        |         |            |       |       |
| `@parameter`         |          |       | yes    |         |            |       |       |
| `@staticmethod`      |          |       | yes    |         |            |       |       |
