The createDefinition hook is triggered when a format definition of a style sheet is imported. It passes the key and value, the original format definition and the data array as arguments and expects an array or null as return value.

Using the createDefinition hook has been deprecated and will no longer work in Contao 5.0. There is no replacement as the internal stylesheet functionality has been removed in Contao 5.0.


  1. string $key

    CSS property of the definition.

  2. string $value

    CSS value of the definition.

  3. string $definition

    Complete CSS definition string.

  4. array $dataSet

    The current data set to be added to the database.

Return Values

An associative array containing the CSS property as key and its value as value or null to keep the default behaviour.


// src/EventListener/CreateDefinitionListener.php
namespace App\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;

class CreateDefinitionListener
    public function __invoke(string $key, string $value, string $definition, array &$dataSet): ?array
        if ('border-radius' === $key) {
            return ['border-radius' => $value];

        return null;