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.

Support `-webkit-appearance` and `-moz-appearance` in style object

See original GitHub issue

Current behavior:

I’m trying to hide the up/down arrow in <input type="number"> in Chrome and the recommended way is to add "-webkit-appearance": "none" and "-moz-appearance": "textfield" to the input. However when I do:

"input::-webkit-outer-spin-button, input::-webkit-inner-spin-button": {
    "-webkitAppearance": "none",
    "margin": 0
},
  "input[type=number]": {
    "-mozAppearance": "textfield"
}

I’m getting an error saying Using kebab-case for css properties in objects is not supported. even when it renders correctly. I think the problem is that processStyleValue needs to whitelist those attributes.

I also tried this:

"input::-webkit-outer-spin-button, input::-webkit-inner-spin-button": {
    "webkitAppearance": "none",
    "margin": 0
},
  "input[type=number]": {
    "mozAppearance": "textfield"
}

But it didn’t get parsed correctly.

Expected behavior: Users should be able to express -webkit-appearance and -moz-appearance via style object. Sorry if this is not an actual bug.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
Andaristcommented, Oct 7, 2020

The correct way to write those is this:

{
  "input::-webkit-outer-spin-button, input::-webkit-inner-spin-button": {
    "WebkitAppearance": "none",
    "margin": 0
  },
  "input[type=number]": {
    "MozAppearance": "textfield"
  }
}

You can check out a working example here: https://codesandbox.io/s/rough-field-wooin

This follows the implementation used by Facebook (and thus probably by React itself): https://github.com/facebook/fbjs/blob/0de589c70c0248ec093ca8e35b6aa6bd16fcac5c/packages/fbjs/src/core/hyphenateStyleName.js

1reaction
LilyMGohcommented, Oct 7, 2020

@Andarist That doesn’t work with TypeScript. Please try it and you’ll get Type '{ WebkitAppearance: string; margin: number; }' is not assignable to type 'Interpolation<undefined>'. compile-time error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

appearance - CSS: Cascading Style Sheets - MDN Web Docs
The appearance CSS property is used to control native appearance of UI controls, that are based on operating system's theme.
Read more >
CSS appearance Property - W3docs
The -moz-appearance property is used in Gecko (Firefox) to show an element using platform-native styling based on the operating system's theme. The -webkit- ......
Read more >
CSS -webkit-appearance - GeeksforGeeks
CSS3 has equivalent appearance property to -webkit-appearance property based on the browser compatibility. Such as -webkit- is replaced by -ms- ...
Read more >
appearance - CSS-Tricks
The appearance property is used to display an element using a platform-native styling based on the users' operating system's theme.
Read more >
CSS Appearance | How does Appearance Property Work in CSS
To add platform-specific style to an item that by default does not have it. To eliminate the unique styling of a platform to...
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