question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[TextField] Outline has Inline Styles

See original GitHub issue

Using the TextField component with the variant prop set to “outlined” will inline a padding-left and width inline style. This is difficult to accommodate for Content Security Policy.

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

All styles provided by material-ui should be inlined in the head tag which contains a CSP nonce

Current Behavior

When implementing TextField, the following HTML is output - note the style attributes

<fieldset aria-hidden="true" class="MuiNotchedOutline-root-174 MuiOutlinedInput-notchedOutline-151" style="padding-left: 8px;">
    <legend class="MuiNotchedOutline-legend-175" style="width: 38px;"></legend>
</fieldset>

Steps to Reproduce

Link: https://codesandbox.io/s/31prwv9j5q

  1. Implement TextField component
  2. add variant=“outlined”
  3. Inspect the fieldset and input elements

Context

This makes implementing a good CSP difficult due to arbitrary inline styles

Your Environment

Tech Version
Material-UI v3.2.2
React v16.5.2
Browser Chrome 69

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
oliviertassinaricommented, Mar 26, 2022

I’m closing as I don’t think that we should stop ourselves to use inline style if it can enable better solutions.

Regrading the very case of the text field, #17680 will very likely remove this inline style.

See #19938 for the general issue with inline-style for CSP.

3reactions
oliviertassinaricommented, Apr 1, 2019

I’m not sure we should fix this issue. We are using inline style at different locations in the code base. cc @mui-org/core-contributors.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[TextField] Outline has Inline Styles #13364 - mui/material-ui
Using the TextField component with the variant prop set to "outlined" will inline a padding-left and width inline style. This is difficult ...
Read more >
border-inline-style - CSS - MDN Web Docs
The border-inline-style CSS property defines the style of the logical inline borders of an element, which maps to a physical border style ...
Read more >
Material UI inline styling - specific component colours
I'm trying to style my TextFields from Material-UI. I have a black background and I need both the textField border and text to...
Read more >
Change text field border color in inline style | Support Center
I need to change the color of the input field depending on the condition. For example: <pega: when name = "testWhen"> border: solid...
Read more >
How to Remove and Style the Border Around Text Input Boxes ...
To have clear fields in your forms, set the outline property to its "none" value, which is used to display no outline. input...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found