Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label and group radio buttons horizontally aligned

I have a label and group radio button (two) and i want to make it to be horizontally aligned like in the picture.

enter image description here

I tried this code:

`<ion-row radio-group [(ngModel)]="Sexe">
  <ion-col>
      <ion-item>
        <ion-label color="primary">Sexe</ion-label>
        <ion-radio value="Mr"></ion-radio>
        <ion-radio value="Mme"></ion-radio>
      </ion-item>
  </ion-col>
</ion-row>`

and also this code:

`<ion-row radio-group [(ngModel)]="Sexe">
  <ion-col>
      <ion-item>
        <ion-label color="primary">Sexe</ion-label>
      </ion-item>
      <ion-item>
        <ion-radio value="Mr"></ion-radio>
      </ion-item>
      <ion-item>
          <ion-radio value="Mme"></ion-radio>
      </ion-item>
  </ion-col>
</ion-row>`

But i don't have the result that I want.

like image 663
zakaria Avatar asked May 28 '17 13:05

zakaria


People also ask

How do I align a radio button horizontally?

To make a horizontal radio button set, add the data-type="horizontal" to the fieldset . The framework will float the labels so they sit side-by-side on a line, hide the radio button icons and only round the left and right edges of the group.

Should radio buttons be horizontal or vertical?

Vertical positioning of radio buttons is safer. Radio buttons are tiny in nature, and, thus, according to Fitts' law, they can be hard to click or tap.

How do you keep a radio button and label on the same line?

As a quick solution either you can apply colspan for your td or You can have both the radio button controls in same td so that the change due to long text wont affect the display of radiobutton.

How do you label a radio button?

To label a radio button, add a <label> element after the <input> element and insert a for attribute with the same value as the id of the associated <input> element. Then, write your label text in the <label> tag.


2 Answers

You can use ion-row and ion-col elements for that. Please take a look at this working plunker.

  <ion-row radio-group [(ngModel)]="sexe">
    <ion-col>
      <ion-item>
        Sexe
      </ion-item>
    </ion-col>
    <ion-col>
      <ion-item>
        <ion-label>Homme</ion-label>
        <ion-radio value="homme"></ion-radio>
      </ion-item>
    </ion-col>
    <ion-col>
      <ion-item>
       <ion-label>Femme</ion-label>
        <ion-radio value="femme"></ion-radio>
      </ion-item>
    </ion-col>
  </ion-row>

Since we use a single row and three columns, the title and the radio items will be placed all in the same row (horizontally aligned).

like image 187
sebaferreras Avatar answered Nov 17 '22 00:11

sebaferreras


<ion-row>
        <ion-label class="ion-label" color=dark>Save</ion-label>
      </ion-row>
      <ion-row radio-group [(ngModel)]="relationship" class="item">

            <ion-col>
                    <ion-radio value="manually" checked></ion-radio>
                    <ion-label>Manually</ion-label>
            </ion-col>

            <ion-col>
                    <ion-radio value="automatic"></ion-radio>
                    <ion-label>Automatically</ion-label>
            </ion-col>

    </ion-row>
like image 1
Sams Avatar answered Nov 17 '22 00:11

Sams