I’m working on a Figma plugin and trying to use a UI component library that was recommended in the official documentation. I installed the package using npm but I’m having trouble getting the local CSS file to load properly.
My current HTML setup:
<link rel="stylesheet" href="node_modules/ui-component-lib/dist/styles.css">
The file path seems correct since my code editor can navigate to it without issues. I’ve tried placing the link element both inside and outside the head section.
What’s strange is that the CDN version works fine:
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/ui-component-lib/dist/styles.css"
/>
However, I want to avoid the CDN approach because it causes a flash of unstyled content while the external stylesheet loads.
Additional context:
Figma renders plugin UIs inside an iframe with this structure:
<iframe>
<html>
<head>
<script></script>
<style></style> <!-- Auto-generated by Figma -->
<link> <!-- My custom link goes here -->
</head>
<body>
<!-- Plugin interface content -->
</body>
</html>
</iframe>
Things I’ve already attempted:
- Moving the link tag to different positions in the HTML
- Testing with other CSS files outside the node_modules directory
Any ideas what might be causing this issue with local file references?