---
title: "Argument ViewHelper <f:argument>"
manual: "Fluid Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/fluid:typo3fluid-fluid-argument"
source: "ViewHelpers/Fluid/Argument.rst"
rendered: "2026-10-08T14:12:40+00:00"
---

# Argument ViewHelper `<f:argument>` {#typo3fluid-fluid-argument}

> [!NOTE]
> This reference is part of the documentation of Fluid Standalone.
> If you are working with Fluid in TYPO3 CMS, please refer to
> [TYPO3's ViewHelper reference](https://docs.typo3.org/other/typo3/view-helper-reference/14.3/en-us/Global/Argument.html) instead.

`f:argument` allows to define requirements and type constraints to variables that
are provided to templates and partials. This can be very helpful to document how
a template or partial is supposed to be used and which input variables are required.

These requirements are enforced during rendering of the template or partial:
If an argument is defined with this ViewHelper which isn't marked as `optional`,
an exception will be thrown if that variable isn't present during rendering.
If a variable doesn't match the specified type and can't be converted automatically,
an exception will be thrown as well.

Note that `f:argument` ViewHelpers must be used at the root level of the
template, and can't be nested into other ViewHelpers. Also, the usage of variables
in any of its arguments is not possible (e. g. you can't define an argument name
by using a variable).

Rendering of specific sections will not validate argument constraints. They
will only be evaluated if the template or partial is rendered directly.

## General Example {#general-example}

For the following partial:

```xml
<f:argument name="title" type="string" />
<f:argument name="tags" type="string[]" optional="{true}" />
<f:argument name="user" type="string" optional="{true}" default="admin" />

Title: {title}<br />
<f:if condition="{tags}">
  Tags: {tags -> f:join(separator: ', ')}<br />
</f:if>
User: {user}
```

The following render calls will be successful:

```xml
<!-- All arguments supplied -->
<f:render partial="MyPartial" arguments="{title: 'My title', tags: {0: 'tag1', 1: 'tag2'}, user: 'me'}" />
<!-- "user" will fall back to default value -->
<f:render partial="MyPartial" arguments="{title: 'My title', tags: {0: 'tag1', 1: 'tag2'}}" />
<!-- "tags" will be "null", "user" will fall back to default value -->
<f:render partial="MyPartial" arguments="{title: 'My title'}" />
```

The following render calls will result in an exception:

```xml
<!-- required "title" has not been supplied -->
<f:render partial="MyPartial" />
<!-- "user" has been supplied as array, not as string -->
<f:render partial="MyPartial" arguments="{title: 'My title', user: {firstName: 'Jane', lastName: 'Doe'}}" />
```

## Union Types {#union-types}

<!-- TODO: no Markdown rendering for "versionchanged" -->

Union types are supported for component arguments.

An argument can allow multiple types. In that case, the component's implementation
needs to make sure that all possible variants are considered. This should be used sparingly
since it can complicate the component's implementation code considerably.

```xml
<f:argument name="number" type="int|float" />
<f:argument name="object" type="Vendor\Package\MyObjectA|Vendor\Package\MyObjectB" />
```

Go to the source code of this ViewHelper: [ArgumentViewHelper.php (GitHub)](https://github.com/TYPO3/Fluid/blob/main/src/ViewHelpers/ArgumentViewHelper.php).

**Arguments**

The following arguments are available for the argument ViewHelper:

-   **default**

    -   *Type:* mixed

    default value for optional argument

-   **description**

    -   *Type:* string

    description of the template argument

-   **name**

    -   *Type:* string
    -   *Required:* true

    name of the template argument

-   **optional**

    -   *Type:* boolean
    -   *Default:* false

    true if the defined argument should be optional

-   **type**

    -   *Type:* string
    -   *Required:* true

    type of the template argument
