简体   繁体   中英

Angular 15 Material bug input on focus when using Tailwindcss

Before focusing:

对焦前

After focusing:

对焦后

Problem:

Using angular mat v. 15 and latest tailwindcss there is a bug when focusing input field.

To reproduce the problem:

ng new angular-test
cd angular-test
ng add @angular/material
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init

tailwind.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/**/*.{html,ts}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

styles.scss

[...]

/* You can add global styles to this file, and also import other style files */

@tailwind base;
@tailwind components;
@tailwind utilities;

app.component.html

<mat-form-field appearance="outline">
  <mat-label>Favorite food</mat-label>
  <input matInput placeholder="Ex. Pizza" value="Sushi">
</mat-form-field>

Any ideas how to solve the problem?

tailwind is adding border-style: solid; which is causing the extra border to be rendered

quick solution would be to override the right border style

add this in the styles.css file

.mat-mdc-form-field.mat-mdc-form-field.mat-mdc-form-field.mat-mdc-form-field.mat-mdc-form-field .mdc-notched-outline__notch {
  border-right-style: hidden;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM