.docname {Variables}
.include {docs}

Variables allow you to store and reuse values throughout your document. They are essential for avoiding repetition, creating dynamic content, and building reusable components.

## Defining a variable

Use **`.var {name} {value}`** to define a variable. The `value` is a [dynamic value](typing.qd), meaning it can be of any type: text, numbers, booleans, or even complex elements like layouts.

```markdown
.var {name} {Quarkdown}
```

## Accessing a variable

Once defined, you can access a variable by calling it as a parameter-less function:

.examplemirror
    .var {name} {Quarkdown}

    Hello, **.name**!

## Reassigning a variable

You can update a variable's value at any point. There are two equivalent ways to do this:

- `.myvar {newvalue}`
- `.var {myvar} {newvalue}`

.examplemirror
    .var {mynumber} {5}

    .mynumber

    .mynumber {.mynumber::sum {1}}

    .mynumber

## Block variables

As mentioned in [Syntax of a function call](syntax-of-a-function-call.qd#the-body-argument):
> A body argument always refers to the last parameter of the signature.

This means a variable's value can span multiple lines and contain complex block content, not just simple inline values. This is powerful for storing reusable layouts, styled containers, or any structured content.

.examplemirror
    .var {myrow}
        .row gap:{2cm}
            A

            B

            C

    .container background:{teal} padding:{1cm}
        .myrow

## Scoped variables

For temporary variables that should only exist within a limited scope, see the [`.let`](let.qd) function. Unlike `.var`, which creates document-wide variables, `.let` creates variables that exist only within a lambda block.
