Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular Material multiple "input" on same row

How can I add multiple inputs on same row? I have tried using bootstrap but for some reason it wont work. If you have some exemple to show me.

<form class="example-form">
  <mat-form-field class="example-full-width">
    <input matInput placeholder="First Name">
  </mat-form-field>

  <mat-form-field class="example-full-width">
    <input matInput placeholder="Last Name">
  </mat-form-field>
</form>
like image 330
Rubyen Avatar asked Apr 24 '18 10:04

Rubyen


2 Answers

Angular Material's inputs are displaying in row by default (see stackblitz below), and may be you override this behavior somewhere in your project, I mean CSS rules. If you like Flexbox, you can use @angular/flex-layout, you can easily control how to display items: in row or in column, and this package is very common among Angular developers. Here is a simple demo with "default" behavior (without any additional rules) and 2 layout options: column and row:

STACKBLITZ

like image 159
Commercial Suicide Avatar answered Nov 15 '22 12:11

Commercial Suicide


You are probably looking at the css style display: block; Change whatever you are looking at to display: inline-block;

edit

Now that you showed some code. Your basic html is fine, it shows the inputs next to each other. So something is wrong inside your example-form or example-full-width classes.

like image 45
Carsten Avatar answered Nov 15 '22 13:11

Carsten