How to import Ant Design css styles in GlobalStyles of styled-components.?

Anton

How i can make an import of antd.css in styled-components? instead of App.css

@import '~antd/dist/antd.css';

The whole purpose is, i want my GlobalStyles from styled-components by default to have all Ant Design styles.

And when i will use elements from AntD it will have all default classes on it.

Dennis Vash

You shouldn't.

NOTE: At this time we recommend not using @import inside of createGlobalStyle. We're working on better behavior for this functionality but it just doesn't really work at the moment and it's better if you just embed these imports in your HTML index file, etc.

Altought you can try:

import { createGlobalStyle, css } from 'styled-components';

const antdCss = css`
  ${import('antd/dist/antd.css')}
`;

const GlobalStyle = createGlobalStyle`
  ${antdCss}
`;

export default GlobalStyle;

Edit busy-williamson-xmodn

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I use GlobalStyles from styled components in next?

Using Ant Design Variables in Styled Components

How to import Ant Design components without default class names?

How to do overlapping styles with Styled Components React?

How to create shared styles using styled components?

Styled components not applying styles

How to apply styles to multiple components using styled components

How to customize Ant.design styles

How to add multiple styles based on property with styled-components?

styled-components - how to set styles on html or body tag?

How to override third party default styles using Styled Components

How to extend Link and NavLink with same styles using Styled Components

Where to put styled components styles

How to extend css emotion styled base components?

How to override CSS class with Styled-Components

How to properly map Css classes in Styled Components

How implement css mixes in styled-components?

How to interpolate a CSS property in styled-components?

How to correctly escape css functions for styled components?

How to add custom components into Ant Design stepper?

React styled-components not applying styles to components

For styled components, how can I make all component styles cascade to .hover component styles?

how to import values to styled components from another file

How can I import local font in Reactjs with Styled Components?

Import style dictionary into styled components

How to merge two styled-components which are in different base components but have similar styles?

Styled-components vs Emotion - How to reapplicate css`style` function on Styled-components

Change inline styles to styled-components

Overriding react components styles with styled component