Problem/Motivation

In field component, 'field__item' class is hardcoded

Proposed resolution

In field.twig, add

{%
  set field_item_classes = [
    'field__item',
  ]|merge(field_item_utility_classes ?: [])
%}

and change the 2 lines with
<div {{ item.attributes.addClass('field__item') }}>{{ item.content }}</div>
to
<div {{ item.attributes.addClass(field_item_classes) }}>{{ item.content }}</div>
We can then use the component like this

{%
  include "radix:field" with {
    field_item_utility_classes: ['ratio', 'ratio-16x9'],
  }
%}

Remaining tasks

1. update field.twig
2. update field.component.yml
3. update documentation

MR is coming ;-)

Issue fork radix-3504338

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phily created an issue. See original summary.

phily’s picture

Status: Active » Needs review

doxigo made their first commit to this issue’s fork.

  • doxigo committed 0c5fbf47 on 6.0.x authored by phily
    Issue #3504338: Add a 'field_item_utility_classes' property to the field...
doxigo’s picture

Status: Needs review » Fixed

Lovely, thanks Philippe, merged

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.