Questions tagged [emotion]

Emotion is a performant and flexible CSS-in-JS library. It's inspired by many other CSS-in-JS libraries like glam, glamor, styled-components and glamorous.

Emotion is a performant and flexible CSS-in-JS library. It's inspired by many other CSS-in-JS libraries like glam, glamor, styled-components and glamorous. It allows you to style applications quickly with string styles or object styles. It has predictable composition to avoid specificity issues with CSS. With source maps and labels, Emotion has a great developer experience and great performance with heavy caching and insertRule in production.

Example

import { css } from 'emotion'

render(
    <div
        className={css`
            color: hotpink;
        `}
    >
        Some text.
    </div>
)

Resources

Packages

Related tags

617 questions
7
votes
1 answer

How to style the paper of a Drawer in MUI?

The Material-UI update MUI 5 advices to stop using makeStyles to define styles. It is recommended to use emotion css. I wonder how to style the paper element of the drawer component. My goal is to handover a custom width to the paper element. How…
vuvu
  • 4,886
  • 12
  • 50
  • 73
7
votes
2 answers

React testing library not rendering Emotion CSS

Running React Testing Library to generate snapshots on JSX which uses the Emotion css prop results in no CSS being rendered. I have tried using the "@emotion/jest/serializer" but still no luck. Component:
7
votes
1 answer

How to use emotion/styled with React and Typescript

I have wrapped my root component in ThemeProvider from @emotion/react which gives me access to props.theme as such: const StyledDiv = styled.div` background-color: ${(props) => props.theme.palette.primary.main}; `; Problem: props.theme is an…
mufasa
  • 1,271
  • 13
  • 18
7
votes
1 answer

EmotionJS with typescript doesn't pass theme type to props in styled components

emotion.d.ts import '@emotion/react'; declare module '@emotion/react' { export interface Theme { colors: { primaryColor: string; accentColor: string; }; } } App.tsx import { Theme, ThemeProvider }…
Twiggeh
  • 1,030
  • 1
  • 12
  • 24
7
votes
3 answers

How to type a React component that accepts another component as a prop, and all of that component's props?

I've got a React component that I can use as follows: // Assuming Link is a component that takes a `to` prop: label label If no as prop is passed, it will assume an…
Vincent
  • 4,876
  • 3
  • 44
  • 55
6
votes
0 answers

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