Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material Radio Label Content Wont Apply Text Wrap CSS Angular

I have a radio group with a fixed width and I would like the button labels to wrap. I have tried adding classes to every part of the html and adding "white-space: normal" to the elements but it just ignores it. How can I make it work?

Here is an example of where I am at

If I add this CSS to the top level styles.scss file it works as intended.

.mat-radio-label-content {
  white-space: normal;
}

But I want to avoid this and keep the css only relevant to the specific component and not app wide.

like image 528
Curtis Avatar asked Dec 19 '17 20:12

Curtis


1 Answers

Wrap your label text in a span with a selector.

    <style>
        .wrap-mat-radio-label {
            white-space: normal;
        }
    </style>

    <mat-radio-group>
        <mat-radio-button>     
            <span class="wrap-mat-radio-label">
                {{ season }}
            </span>
        </mat-radio-button>
    </mat-radio-group>
like image 97
Mark Avatar answered Sep 28 '22 04:09

Mark