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

# Fragment ViewHelper `<f:fragment>` {#typo3fluid-fluid-fragment}

> [!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/Fragment.html) instead.

`f:fragment` is the counterpart of the [\<f:slot> ViewHelper](https://docs.typo3.org/permalink/fluid:typo3fluid-fluid-slot).
It allows to provide multiple HTML fragments to a component, which defines
the matching named slots. `f:fragment` is used directly inside a component
tag, nesting into other ViewHelpers is not possible.

## Default Fragment Example {#default-fragment-example}

If the following template `Text.html`:

```xml
<f:argument name="title" type="string" />

<div class="textComponent">
    <h2>{title}</h2>
    <div class="textComponent__content">
        <f:slot />
    </div>
</div>
```

is rendered with the following component call:

```xml
<my:text title="My title">
    <f:fragment>
        <p>My first paragraph</p>
        <p>My second paragraph</p>
    </f:fragment>
</my:text>
```

it will result in the following output:

```xml
<div class="textComponent">
    <h2>My title</h2>
    <div class="textComponent__content">
        <p>My first paragraph</p>
        <p>My second paragraph</p>
    </div>
</div>
```

## Multiple Named Slots {#multiple-named-slots}

If the following template `TextMedia.html`:

```xml
<f:argument name="title" type="string" />

<div class="textMediaComponent">
    <h2>{title}</h2>
    <div class="textMediaComponent__media">
        <f:slot name="media" />
    </div>
    <div class="textMediaComponent__content">
        <f:slot name="content" />
    </div>
</div>
```

is rendered with the following component call:

```xml
<my:textMedia title="My title">
    <f:fragment name="media">
        <img src="path/to/image.jpg" alt="..." />
    </f:fragment>
    <f:fragment name="content">
        <p>My first paragraph</p>
        <p>My second paragraph</p>
    </f:fragment>
</my:textMedia>
```

it will result in the following output:

```xml
<div class="textMediaComponent">
    <h2>My title</h2>
    <div class="textMediaComponent__media">
        <img src="path/to/image.jpg" alt="..." />
    </div>
    <div class="textMediaComponent__content">
        <p>My first paragraph</p>
        <p>My second paragraph</p>
    </div>
</div>
```

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

**Arguments**

The following arguments are available for the fragment ViewHelper:

-   **name**

    -   *Type:* string
    -   *Default:* 'default'

    Name of the slot that should be filled
