Render arrays are great for styling elements to keep consistency across future updates. Today: buttons.

    $inviteButton = [
      '#type' => 'button',
      '#value' => t('Invite contact person'),
      '#attributes' => [
        'class' => ['button', 'button--action', 'button--small', 'button--danger'],
    return [
      '#markup' => Markup::create(render($inviteButton)),

This will look like this:

Drupal 8 render array button
Render a button with render array


Saved you some valuable time?

Donate and get more free time-saving code on this website in the future.