All Questions
51 questions
0
votes
0
answers
52
views
CSS linear-easing-function bug
Edit: add full html code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" ...
0
votes
1
answer
147
views
How to select hardcoded CSS class with Vanilla Extract?
I’m migrating from Emotion to Vanilla Extract. I have a component which contains a third-party UI library component. This third-party component has a hardcoded class .ClassWhichICannotChange.
In ...
3
votes
1
answer
1k
views
How to use material-ui styled components inside Next.js server components
I'm using Next.js version 14 with app router alongside with Material-UI v5.
Whenever I'm rendering Material-UI components in server pages components It's working just fine. The issue starts when I'm ...
6
votes
0
answers
1k
views
integrating emotion/css with nextjs app router
I have been using emotion/css for my project and want to migrate to nextjs app router but have some questions regarding emotion/css server side rendering with app router.
Nextjs documentation states ...
-1
votes
1
answer
84
views
@import not showing Fontawesome icons in CSS-in-JS
This was how I was importing Fontawesome icons:
src/App.css
@import "@fortawesome/fontawesome-free/css/all.css";`
When I moved that @import to CSS-in-Js (emotion):
src/App.js
// JS:
const ...
0
votes
1
answer
239
views
how can I use @ rules in emotion?
I wanna use @Property in emotion ,but cannot find something about this in document
import styled from '@emotion/styled';
import React from 'react';
import demo from './demo_img.jpeg';
const ...
2
votes
0
answers
111
views
How can I use emotion/styled in my react project on codepen?
I need to be able to use @emotion/styled CSS-in-JS library so I can pass props to the background-color and color properties of my Button component. The background-color and color of the buttons are ...
1
vote
0
answers
101
views
How to implement multiple class selectors like .a.b in Emotion?
I'm migrating some CSS to Emotion, some selectors are like .a.b {...}. What's the best way to use Emotion for this?
I've tried css`.${a}.${b}` but it doesn't work :(
0
votes
1
answer
539
views
How to add conditional props to style object in @emotion/react/Typescript?
I want to add props to control my css in emotion,but I don't know how to do
1
vote
1
answer
642
views
Sibling Selectors not working correctly with Emotion
I have the following code:
const CardContainer = styled(Flex)`
flex-direction: column;
padding: 12px;
width: 100%;
max-width: 450px;
height: auto;
border-radius: 32px;
overflow: hidden;
...
0
votes
1
answer
487
views
twin.macro preflight styles differ from tailwind preflight
According to my research and twin.examples repo for Next.js, twin.macro recommends adding their preflight component, which they name <GlobalStyles />. They often alias it to <BaseStyles /> ...
4
votes
1
answer
1k
views
default "css-" class names using MUI styled-components
I'm using Mui's styled components, and i've noticed it injects a class that starts with "css-"
and replaces the class name i've given to it in the code
I've tried to follow everything that ...
1
vote
2
answers
1k
views
TS error using css "position" when passing style object to Emotion's css prop
I have a React component roughly with this structure:
// This does not work.
const style = {
position: 'absolute'
// ...other css props
}
const Component = () => {...
0
votes
3
answers
3k
views
Why does @emotion/styled not render the styled component on screen?
I am trying to use @emotion/styled. But, I cannot get the components to render on the screen, whereas if I am using the HTML element it is working fine.
import styled from "@emotion/styled";
...
2
votes
1
answer
1k
views
How to exernalize @emotion/react, and @emotion/styled for Create React App
I have the following architecture:
main-frontend
foo-frontend
bar-frontend
baz-frontend
main-frontend, foo-frontend, bar-frontend and baz-frontend are all standard React apps generated using ...
1
vote
1
answer
688
views
How to achieve the same effect for hover in emotion?
say I have this in a css file:
.a-hover {
background-color: red;
}
.a-hover:hover {
background-color: blue;
}
.b.a-hover {
background-color: yellow;
}
.b.a-hover:hover {
background-color: ...
0
votes
1
answer
1k
views
What is considered the best way to style components in React with Emotion in terms of readability and performance?
I guess there are 3 main ways to style components in Emotion
<div
className={
css`
height: 150px;
display: flex;
padding: ${theme.defaultUnit}px ${theme....
1
vote
1
answer
3k
views
filter icon in material-ui's v5 DataGrid
The default behavior for the new DataGrid is to hide a filter icon unless you hover over the column header (and have a filter applied). In the previous version the icon remained visible.
Codesandbox ...
7
votes
0
answers
2k
views
How to add CSP nonce for emotion generated styles in storybook webpack config?
We're adding style src 'self' to the HTML page and emotion is generating styles dynamically to the header like below
<head>
<style data-emotion>
...
</style>
<...
5
votes
2
answers
2k
views
Is there an analog of Emotions 'css' function in MUI 5?
As I understand MUI 5 uses Emotion under the hood for styling, Emotion has this nice helper function css that looks like returns a string - a class name that you could use as a value for className or ...
24
votes
5
answers
27k
views
Material UI 5 class name styles
I migrated from Mui 4 to 5 and wonder how to use class names. If I want to apply certain styles to just one component there is the SX property. However, I'm struggling with using the same class for ...
3
votes
0
answers
901
views
Analyzing the performance of emotion/css-in-js in our app
While emotion is great for the developer experience, it does have an affect on how the speed of an application. This article serves as a great reference: https://calendar.perfplanet.com/2019/the-...
1
vote
0
answers
1k
views
Use emotion css function without exposing the component name in output class name
Added css to element as below:
/** @jsxRuntime classic */
/** @jsx jsx */
import { jsx, css } from '@emotion/react';
function Icon() {
return (
<span
css={css`
...
0
votes
1
answer
1k
views
Styled-components, Styled-system, emotion and theme-ui?
Can someone explain the differences between Styled-components, Styled-system, emotion and theme-ui. And additionally, how does these libraries fit into MDX environment?
NB:
I have gone through all of ...
0
votes
1
answer
1k
views
className will be delete in emotion
question desc:
1.My react component:
const Test = ({...other}) => {
const defaultStyle = { '&.test-class-name': {fontSize: 20} }
return <div className={'test-class-name'} css={{color:...
2
votes
1
answer
5k
views
What is the preferred way of passing styles to children in React & Emotion JS?
I'm just getting started with emotion after working with react-jss for a few years. One thing I'm struggling to find a good example of is passing (some, possibly dynamic) styles to a child component. ...
6
votes
0
answers
1k
views
How to handle import rules with emotion?
How to handle CSS @imports with Emotion? I have recently upgraded to version 11 and it emits following error:
`@import` rules can't be after other rules. Please put your `@import` rules before your ...
1
vote
0
answers
584
views
@emotion/react Syntax highlighting doesn't work
I work on react project and use emotion library for styling inside .js file. Syntax highlighting in @emotion/styled works with no issue, but css function from @emotion/react causes some sort of syntax ...
1
vote
3
answers
4k
views
React - How to use GlobalStyles for Google Fonts with Emotion
I am using Emotion, as my css-in-js and I admit, I am fairly new to it. I have spend 1+. hour, to figure out how to inject global styles, and add a google font, to my entire app.
I tried:
The ...
4
votes
1
answer
3k
views
Inline CSS using Emotion in React
Broadly speaking, I appear to have found a discrepancy in the Emotion documentation. On the Introduction page, we are introduced to styling components with the following syntax,
import { css, cx } ...
0
votes
1
answer
1k
views
React and CSS-IN-JS - float labels not detecting the autocomplete
Firstly I am quite new to the react and CSS-IN_JS so this may be a noob question. But I was unable to find a good answer for this.
I am trying to implement floating labels for my react-project in the ...
4
votes
3
answers
17k
views
Tailwind CSS :before pseudo class
I've now been working in circles trying to understand what is happening. I'm making a design library using storybook with Tailwind. I can't seem to get the :before pseudo class to work. No matter ...
1
vote
1
answer
1k
views
Using transition in a styled component with @emotion/core
I am trying to implement a short transition to when a button is clicked.
The mechanism that sets the isOpen property works fine.
My problem is that it won't animate, but only flip the content at once.
...
1
vote
0
answers
486
views
Can I style the Netlify CMS preview with Theme UI and/or Emotion?
I have a Gatsby project that uses Theme UI and Netlify CMS.
How can I style the Netlify CMS preview pane with my Theme UI styles?
Netlify CMS doesn't support CSS-in-JS libraries:
https://github.com/...
0
votes
1
answer
341
views
How to structure a grid layout
So I'm having trouble with the following CSS:
const Content = styled("div")`
grid-area: main;
background-color: white;
margin-top: 5px;
margin-left: 20px;
margin-right: 20px;
display: ...
0
votes
1
answer
794
views
Gatsby and Theme-UI ColorModeProvider
I was experimenting with various font loading strategies with Gatsby and ended up coping over the source of gatsby-plugin-theme-ui so I can update theme.fonts values once all the fonts are loaded by ...
3
votes
1
answer
1k
views
What does the Emotion CSS macro do, and how do I use it?
In Emotion v10 the docs say "There is a Babel macro available for css from @emotion/core if you import it from @emotion/css/macro though." This is apparently available for users who don't have the ...
4
votes
3
answers
10k
views
Why is my local font not being applied with Emotion global styling?
I am trying to use a locally hosted font in a React project that utilizes Emotion, and its Global component. This method works great for web fonts, like Google Fonts, but when I downloaded that same ...
0
votes
1
answer
482
views
Component Libraries that Integrate with Theme-UI
Theme-UI has a number of built-in compoments. But they are all 'simple' components. That is to say, no tabs, accordions, sortable tables or other components that have more 'sophisticated' ...
1
vote
1
answer
4k
views
Overriding styled-components with `css` prop in Emotion
I'm trying to override the base styles of an Emotion styled component with some inline styles - specifically a css prop. The inline styles are not applied using the css prop however, and the only ...
9
votes
2
answers
7k
views
Media Queries in Emotion Styled Components
The Emotion docs tell us how to make reusable media queries that works in the css prop. This allows us to make the following queries in a css prop:
<div
css={{
color: 'green',
[mq[0]]: {...
0
votes
1
answer
1k
views
Emotion - pass style object to external library
I am using reactjs-popup, and one of it's props is contentStyle, which allow you to pass css-in-js object to style an internal div in the library.
however when I pass css object with @media in it, ...
6
votes
1
answer
6k
views
How to use the :first-of-type rule inside a styled-components/emotion partial?
I'm trying to replicate some CSS in Emotion using Partials but I don't see how it's possible to replicate a rule like :first-of-type in a situation where I'm using a partial. Is there some way to ...
4
votes
2
answers
13k
views
Target another component on hover using emotion-js
I understand this is very similar to Target another styled component on hover
However I would like to achieve the same effect with emotion-js
More specifically I am trying to recreate this example ...
3
votes
2
answers
1k
views
How to mutate CSS custom property color with CSS-in-JS?
Suppose I have the following code with emotion's css`` prop:
<div css={css`
background: var(--bg);
`}>
But I would like to darken the background of this div.
Using sass this would be simple ...
1
vote
0
answers
337
views
Emotion css not rendering after deploy to netlify but works locally
I have deployed a gatsby site on netlify which when viewed doesnt render the css for certain elements, my buttons, but works for other elements like my boxes.
It works and renders fine when i run the ...
21
votes
1
answer
34k
views
How to pass props to a styled component in emotion? Using TypeScript
I am using styled by emotion at:
import styled from '@emotion/styled'
I am trying to pass props to a styled component like the guide mentions:
https://emotion.sh/docs/styled
It doesn't work for ...
3
votes
1
answer
2k
views
Override Material UI Tab Indicator Emotion Styled
Trying to figure out how to override the styles of the tabs indicator using styled from Emotion. I am not sure how to access nested classes. This is what I have, but it isn't getting me there:
...
26
votes
2
answers
9k
views
What does the comment /** @jsx jsx */ do in the Emotion CSS-in-JS library?
This seems to be a best practice, since it is used almost everywhere. However, nowhere is it clearly explained what exactly it does ...
I did find a comment in the docs that said:
"This comment ...
15
votes
3
answers
9k
views
How to style body tag with CSS-in-JS approach?
I am a beginner to CSS-in-JS and emotion, and trying to port a sass react app to emotion. Right from the start I already have the issue of not knowing how to style the body tag.
Do people generally ...