I did some research regarding adding custom CSS classes in the message but could not find the actual solution.
As per Drupal 9 documentation:
\Drupal::messenger()->addMessage(t($message));
public function addMessage($message, $type = self::TYPE_STATUS, $repeat = FALSE);
I don't find the option to add CSS class. On the frontend, I would like to add custom CSS class custom-messages--status
in the outputted <div>
so that I can format it as desired:
<div class="col-md-12 messages custom-messages--status">Successfully submitted.</div>