Add features of link attributes module to core's link module

Created on 19 April 2021, about 4 years ago
Updated 24 June 2025, 12 days ago

Problem/Motivation

Core's link widget doesn't provide a way for users to set attributes on links such as

  • id
  • class
  • target
  • rel
  • accesskey
  • aria-label
  • title

But this is a common use case.

The link attributes β†’ module provides this widget, as well as a plugin system to allow module-developers and themes to expose more attributes for possible inclusion.

The project has 30,000 installs on D8+

The project allows you to nominate the form element to use for each attribute via the plugin system (which is yaml based).

A module developer can expose a new data-attribute using this yaml:

data-foo-attribute:
  title: 'Some attribute'
  options:
    foo: Foo
    bar: Bar
  type: select

The keys roughly map to the form API elements.

Having a plugin manager that has a list of known attributes also allows for Drupal to have knowledge of what attributes are in use on a site.

This could be useful in a filtering context

Proposed resolution

Adapt the link attributes module for core by bringing its functionality/features into the core link module.

Remaining tasks

User interface changes

API changes

A new plugin system for allowed attributes
A new widget for link items

Data model changes

None, Link attributes makes use of the fact that core's link field has an options property, but just no way to set values in it.

✨ Feature request
Status

Active

Component

General

Created by

πŸ‡¦πŸ‡ΊAustralia larowlan πŸ‡¦πŸ‡ΊπŸ.au GMT+10

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    The Ideas project is being deprecated. As discussed in a core committer meeting issues that are adding modules are being moved to the Drupal CMS project for discussion.

  • πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia
  • πŸ‡¦πŸ‡ΊAustralia pameeela

    This is a pretty specific request to add relatively simple functionality to core itself. Drupal CMS could add the link attributes module but that's not really what's being requested. I think it makes sense to evaluate the request for core first?

Production build 0.71.5 2024