Skip to content

Installation

Requirements

  • Drupal 8, 9, 10, or 11.
  • The core Custom Menu Links module (menu_link_content).

Install

composer require drupal/menu_link_attributes
drush en menu_link_attributes

Or enable Menu Link Attributes at Extend (/admin/modules).

The module ships with three attributes: container_class, class, and target. Change or remove them on the configuration page.

Optional: YAML Editor

The configuration form is a plain textarea. Install YAML Editor for syntax highlighting and indentation help. The configuration page shows a warning until it is installed. Configuration has screenshots of both.

composer require drupal/yaml_editor
drush en yaml_editor

Permissions

Grant these at People > Permissions (/admin/people/permissions):

Permission Machine name Allows
Administer menu link attributes administer menu link attributes Defining the available attributes. Restricted.
Use menu link attributes use menu link attributes Filling in attribute values on the menu link form.

Users without Use menu link attributes do not see the attribute fields, even with Administer menu link attributes. Existing values on a link are kept when such a user saves it.