Official way to add custom theme CSS #23
Replies: 3 comments 2 replies
-
I'm assuming, you're using one of the setups. They're very limited when it comes to customization currently, but I could definitely make it possible to register new themes that the setups can use. An API that could easily work would be something like this: import { registerTheme } from "prism-code-editor/themes"
registerTheme("my-theme", () => import("./my-theme.css?inline")) This example would work with Vite, but might be different if you're using another bundler. The second argument to If this sounds useful to you, I can add this proposed |
Beta Was this translation helpful? Give feedback.
-
With regards to customizing styles, would it be possible to add the ::part() CSS selector and exportparts into the injected element wrapper since CSS Shadow Parts allow web components authors to provide public styling API. that is, when rendering, the result html will contain <div class="prism-code-editor language-javascript show-line-numbers pce-nowrap pce-no-selection pce-readonly" part="prism-code-editor-part" style="tab-size: 2; --number-width: 1.001ch;">
<div class="pce-wrapper">
<div class="pce-overlays">
<textarea spellcheck="false" autocapitalize="off" autocomplete="off" inputmode="none" aria-readonly="true">
</textarea>
<!-- ... -->
</div>
<!-- ... -->
</div>
</div> this is mostly just a feature request since this was the only way i could select this element in my styles files, at the moment, like ::part(prism-code-editor-part):hover {
--editor__bg-scrollbar: 210, 10%, 40%;
} and probably due to how shadow DOM styling works in the framework I am using, I've programmatically got the html element and manually added the part attribute. of course this is just a feature request and since I did not really need a full theme change as I just wanted to make small changes like I am not sure of what other implications will be introduced when adding part attribute in your library, so the request can be denied if it will negatively affect some other parts I'm not aware of. |
Beta Was this translation helpful? Give feedback.
-
Version 3.4.0 is out, and the |
Beta Was this translation helpful? Give feedback.
-
I couldn't find an official way to load in custom theme CSS. It'd be cool to have a way to register custom themes so we can switch to them by name.
Beta Was this translation helpful? Give feedback.
All reactions