---
title: "Switch ViewHelper <f:switch>"
manual: "Fluid ViewHelper Reference"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3viewhelper:typo3fluid-fluid-switch@main"
source: "Global/Switch.rst"
modified: "2026-09-17T05:12:06+00:00"
---

# Switch ViewHelper `<f:switch>`

Switch ViewHelper which can be used to render content depending on a value or expression.
Implements what a basic PHP `switch()` does.

An optional default case can be specified which is rendered if none of the
`case` conditions matches.

Using this ViewHelper can be a sign of weak architecture. If you end up using it extensively
you might want to consider restructuring your controllers/actions and/or use partials and sections.
E.g. the above example could be achieved with `<f:render partial="title.{person.gender}" />`
and the partials "title.male.html", "title.female.html", ...
Depending on the scenario this can be easier to extend and possibly contains less duplication.

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

## Arguments of the `<f:switch>` ViewHelper

-   **expression**

    -   *Type:* mixed
    -   *Required:* true

    Expression to switch
