Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add React UI library ant-design, but have no css style #6497

Closed
1 task
LiMao00 opened this issue Mar 10, 2023 · 3 comments
Closed
1 task

add React UI library ant-design, but have no css style #6497

LiMao00 opened this issue Mar 10, 2023 · 3 comments

Comments

@LiMao00
Copy link

LiMao00 commented Mar 10, 2023

What version of astro are you using?

2.0.17

Are you using an SSR adapter? If so, which one?

none

What package manager are you using?

pnpm

What operating system are you using?

windows

What browser are you using?

chrome

Describe the Bug

add React UI library ant-design, but have no css style

the git is https://gitee.com/limao-xs/lm-astro-basics

because have the question(https://hub.nuaa.cf/vitejs/vite/issues/11064), I rewrite the defineConfig

export default defineConfig({
	integrations: [react()],
	// <<<<<<<<<<<<<<<<<<<<<<<<< m_sp m
	vite: {
		resolve: {
			alias: {
				"antd/dist/reset.css": path.join(
					__dirname,
					"node_modules/antd/dist/reset.css"
				),
				antd: path.join(__dirname, "node_modules/antd/dist/antd.js"),
			},
		},
	},
);

but how to import the antd/dist/reset.css?

now:
image

expectation:
image

Link to Minimal Reproducible Example

https://gitee.com/limao-xs/lm-astro-basics

Participation

  • I am willing to submit a pull request for this issue.
@LiMao00 LiMao00 changed the title add React UI library antd, but have no css style add React UI library ant-design, but have no css style Mar 10, 2023
@matthewp
Copy link
Contributor

Please provide a small reproduction via astro.new and we can take a look. Thank you!

@brycehanscomb
Copy link

Ant Design components are built with a CSS-in-JS solution, so they need JS running on the client to have any styles.

Astro requires you to opt-in to client-side JS with the client:load directive.

Add that to your React component and it should have styles applied.

@ChemaCLi
Copy link

Ant Design components are built with a CSS-in-JS solution, so they need JS running on the client to have any styles.

Astro requires you to opt-in to client-side JS with the client:load directive.

Add that to your React component and it should have styles applied.

Thanks! It works. Now I'm having an common and annoying behavior: the ant design flash 💥
This happens using NextJS too.

There is a workaround on Next. I'll try something similar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants