Add core's button CSS classes by default

Created on 15 January 2025, 5 months ago

Problem/Motivation

Similar links found in Drupal core-supplied Views, like the admin/content page, have the appereance of a button, so I suggest we use the already provided CSS classes to improve the styling.

Proposed resolution

This could be made by adding these default CSS classes:
button button--action button--primary

If there isn't a way for a recipe to define that, I suggest we change line 128 of /src/Plugin/views/area/AddContentByBundle.php to
'#default_value' => $this->options['class'] ?: 'button button--action button--primary',

Remaining tasks

  • Decide
  • Provide a MR
📌 Task
Status

Active

Version

1.2

Component

Miscellaneous

Created by

🇮🇹Italy kopeboy Milan

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

Comments & Activities

  • Issue created by @kopeboy
  • 🇫🇷France erwangel

    Also I would be nice to set the link in a container so we can theme it easier.

        // Assemble elements into a link render array.
        $element = [
          '#type' => 'link',
          '#title' => $this->options['label'],
          '#url' => $url,
          '#options' => [
            'attributes' => ['class' => $classes],
          ],
         // Add wrapper
         '#prefix' => '<div class="$some_classes">,
         '#suffix' => '</div>',
         //
          '#access' => $access,
        ];
    
    
Production build 0.71.5 2024