[bug]:

Open
#79 2 comments 2 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
css, react, typescript
Domain
frontend

Research direction

Start with admin/src/components/MyComponent.tsx and its imported style.css, then reproduce the issue using yarn run watch:link, yalc add strapi-plugin-name, and yarn run develop. Inspect the built plugin and Strapi Admin UI to determine why the CSS is present in dist but not applied. Done means the custom-style rules from style.css are loaded and visible in the Admin Panel.

Written by the indexing model from the issue text.

Description

issue: bug
What version of @strapi/sdk-plugin are you using?

-Strapi V5
-@strapi/[email protected]
[email protected]

What's Wrong?

I'm trying to load a style.css file to customize some elements in my Strapi plugin, but the file is not being rendered or loaded in the DOM.

I've created a component with an associated CSS file and imported it into my .tsx file. When I build the project, both files are included in the dist folder, but the styles are not applied in the Strapi admin panel.

Image

Do you have any suggestions on how I can properly load my CSS in Strapi?

To Reproduce
  1. Create a com1ponent with a CSS file

Add a MyComponent.tsx file inside the admin/src/components folder.
Add a style.css file inside the same folder.
Import the CSS file in the component

  1. Import css
import "./style.css";

const MyComponent = () => {
    return <div className="custom-style">This is my component</div>;
};

export default MyComponent;

Ensure the CSS file is included in the build output

3/Ensure the CSS file is included in the build output
Run "yarn run watch:link" in the plugin repository to watch for changes.

4.Run Strapi and check the Admin UI
In a separate Strapi project, install the plugin via yalc add strapi-plugin-name.
Start Strapi with "yarn run develop".
Navigate to the plugin interface in the Strapi Admin Panel.
Observe that the styles from style.css are not applied.

Expected Behaviour

The style.css file should be loaded and applied to the component in the Strapi Admin Panel.

Dominant language
TypeScript
Stars
24
Forks
13
Avg merge
5d 3h
Merged PRs (30d)
5

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from strapi/sdk-plugin

All issues in strapi/sdk-plugin

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.