---
title: "div foreach · RUAL Documentation"
description: "Serves as a dynamic container, generating an unique div for each element in the specified array."
canonical: https://docs.rual.nl/block-types/state%20ui/state_foreach_div
language: en
---

[Cluster](https://docs.rual.nl/cluster)

[Blocks](https://docs.rual.nl/block-types)

[Interfaces](https://docs.rual.nl/interfaces)

[Blueprints](https://docs.rual.nl/blueprints)

[Tutorials](https://docs.rual.nl/tutorials)

[Home automation](https://docs.rual.nl/home-automation)

[Examples](https://docs.rual.nl/examples)

[Reference](https://docs.rual.nl/reference)

[Architecture](https://docs.rual.nl/architecture)

[Troubleshooting](https://docs.rual.nl/troubleshooting)

Other

# div foreach

This block is part of the [`state ui`](https://docs.rual.nl/block-types/state%20ui) group and was last modified in core [`v13.0.6`](https://docs.rual.nl/core-versions/130006).

## Type Selection Required

This block requires you to select the data type you want to work with. You must manually select the type using the type selector modal. To access the modal, click the white button on the block.

Serves as a dynamic container, generating an unique `div` for each element in the specified array.

- array required `array` This array is the source of data for generating the individual div elements. • Hidden when other fields are filled

- state key required `v13.0.4` `value` This state key is the source of data for generating the individual div elements. • Hidden when other fields are filled

- class `uiclass` Assigns a CSS class to the element. • Hidden when unused

- style `uistyle` Applies inline CSS style to the element • Hidden when unused

- attributes `uiattributes` Adds custom attributes to the element. • Hidden when unused

- state `state` Returns the element to the frontend state.

- iterator `execute_function` Allows you to execute a custom function to determine the content of each div element.

A typical wiring for [div foreach](https://docs.rual.nl/block-types/state%2520ui/state_foreach_div): [with values](https://docs.rual.nl/block-types/array/array_of_values) feeds the `array` pin; [value](https://docs.rual.nl/block-types/value/value_default) feeds the `state` pin; the function out pin wires to an [execute](https://docs.rual.nl/block-types/function%2520execution/function_custom_execute_from_trigger) block.

[![Studio canvas example for the div foreach block: typical wiring for div foreach.](https://docs.rual.nl/canvas-examples/state_foreach_div.png)](https://docs.rual.nl/canvas-examples/state_foreach_div.png?v=3)

## Version history

Introduced in [`v13.0.1`](https://docs.rual.nl/core-versions/130001).

Last modified in [`v13.0.6`](https://docs.rual.nl/core-versions/130006).

- [v13.0.4](https://docs.rual.nl/core-versions/130004): This block or one of its pins was updated in `v13.0.4`, click here to see the release notes.

- [Back to `state ui`](https://docs.rual.nl/block-types/state%20ui): Return to the main group to view all sub-groups

- [Back to `state elements`](https://docs.rual.nl/block-types/state%20ui?group=state%20elements): Return to the group to view all blocks within this group

Was this page helpful? [Tell us what to improve](https://docs.rual.nl/support) · RUAL Docs is an integral component of the [RUAL ecosystem](https://rual.nl)
