Hello, anyone knows how can I add a file admin.css on the CMS?
I want to change a bit the CSS from the CMS widgets.
I am using Gatsby and I don’t have any index.html to add the CSS and after importing it on the cms.js, I realized it just styles the <iframe> element of the window preview.
Hello @luke, thank you for the reply! I don’t want take any credit on this, I got this code from a template. In the beginning of the year I’ve tried already to use this code, but it didn’t work on that time.
To clarify that you can add custom css as indicated in the docs.
Add <script>CMS.registerPreviewStyle("/admin/admin.css");</script> before the </body> in index.html as such:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Content Manager</title>
<!-- Include the script that enables Netlify Identity on this page. -->
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
</head>
<body>
<!-- Include the script that builds the page and powers Netlify CMS -->
<script src="https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js"></script>
<script>CMS.registerPreviewStyle("/admin/admin.css");</script>
</body>
</html>
Then add your custom styling to admin.css. Here’s a start:
body {
margin: 0;
background-color: #faf9f9;
color: #9d4e48;
}
.frame-content {
margin: 1rem;
}
.frame-content > div > div + div {
margin-top: 0.5rem;
border-top: 1px dashed #dfdfe3;
padding-top: 0.5rem;
}
Make sure that the admin.css is available in a static folder, mine is under /static/admin/admin.css for Nuxt.
I am using gatsby CMS and this did not work - I have the cms-utils.js and have tried to make changes to static/admin/admin.css, but nothing changes in my deploy preview - I know my changes are being pushed, the site updates with .md file changes and I can see the admin.css file in the repo. Does anyone know why this might be?