Submitted by admin on Wed, 05/29/2024 - 13:33

In one of design we have to add different background colors to each row of title for reference i am adding some screenshots to see what actual problem was and how we overcome from this.
we have found a way to add class by title value from view itself and can easily add styling to each title.
Here are the steps to achieve this feature in your drupal 10 view -
1. Go to your view

2. Configure field on which you want different classes in my case it is field_tags.

3. Now go to style settings and enable Customize field HTML.

4. Add HTML class 

5. In CSS class add this - {{ field_tags }} 
*Note - the value we can get from rewrite results -> 
Override the output of this field with custom text -> Replacement patterns.
 

6. Apply and Save view.1

 

2

Solutions Img