brunam
brunam

Reputation: 835

Material Components input text field being cut off

Just running barebones "material-components-web" and I can't get the input field to look like it's supposed to. JS interaction is working great. Theme looks good. But my field is getting cut offenter image description here

index.html:

<html>
 <head>
   <link rel="stylesheet" href="bundle.css">
   <link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,700,700i" rel="stylesheet">
 </head>
 <body class="mdc-typography">
    <h1 class="mdc-typography--headline1">Big header</h1>
    <div class="mdc-text-field" data-mdc-auto-init="MDCTextField">
      <input class="mdc-text-field__input" type="text" id="input">
      <label for="input" class="mdc-floating-label">Input Label</label>
      <div class="mdc-line-ripple"></div>
    </div>

    <!-- at the bottom of the page -->
    <script src="bundle.js"></script>
</body>
</html>

app.scss:

@import "material-components-web/material-components-web";

app.js:

import * as mdc from 'material-components-web'
mdc.autoInit()

I have no other files pulling in. No other styles added. What could be happening?

Upvotes: 0

Views: 3054

Answers (2)

Keir Finlow-Bates
Keir Finlow-Bates

Reputation: 1053

The following worked for me: add the following to a custom style sheet.

.mdc-text-field {
  width: -webkit-fill-available;
  width: fill-available;
}

Upvotes: 0

Rustem Gareev
Rustem Gareev

Reputation: 814

That usually happens when .mdc-text-field__input has incorrect box-sizing (for example, inheriting parental .mdc-text-field's border-box). Please ensure that .mdc-text-field__input has initial box-sizing:

.mdc-text-field__input {
  box-sizing: initial; // or content-box
}

Upvotes: 1

Related Questions