Below is the angular material code i am using to display radio buttons :
<div>
<mat-radio-group>
<mat-radio-button value="1">Transcription</mat-radio-button>
<mat-radio-button value="2">Summarization</mat-radio-button>
<mat-radio-button value="3">Both</mat-radio-button>
</mat-radio-group>
</div>
But this is displaying the radiobuttons horizontally. But i need them to be displayed vertically.
Radio-buttons should typically be placed inside of an <mat-radio-group> unless the DOM structure would make that impossible (e.g., radio-buttons inside of table cells). The radio-group has a value property that reflects the currently selected radio-button inside of the group.
You can use CSS to get this done, add a class to your mat-radio-group
where you can use:
display: flex; flex-direction: column;
display: grid;
display: inline-grid;
relevant HTML:
<div>
<mat-radio-group class="example-radio-group">
<mat-radio-button value="1">Transcription</mat-radio-button>
<mat-radio-button value="2">Summarization</mat-radio-button>
<mat-radio-button value="3">Both</mat-radio-button>
</mat-radio-group>
</div>
relevant CSS:
.example-radio-group {
display: flex; flex-direction: column;
/* display: inline-grid; */
/* display: grid; */
margin: 15px 0;
}
working stackblitz here
Simply add a <br>
tag after each <mat-radio-button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With