svelte-highlight-switcher
TypeScript icon, indicating that this package has built-in type declarations

1.2.12Β β€’Β PublicΒ β€’Β Published

svelte-highlight-switcher

npm-version npm-license npm-download-month npm-min-size ci.yml website

πŸ“ Safe svelte-highlight dynamic style switching

Hides the use of @html and reduces the risk of XSS.

Installation

npm i svelte-highlight-switcher

Example

<script>
  import { HighlightSwitcher } from 'svelte-highlight-switcher'

  let isDarkMode = false
</script>

<HighlightSwitcher name={isDarkMode ? 'githubDark' : 'github'} />

↓ This is equivalent to the following code

<script>
  import * as styles from 'svelte-highlight/styles'

  let isDarkMode = false
</script>

<svelte:head>
  {@html isDarkMode ? styles['githubDark'] : styles['github']}
</svelte:head>

As long as the contents of svelte-highlight/styles are secure, there is no risk of XSS.

License

MIT

Package Sidebar

Install

npm i svelte-highlight-switcher

Weekly Downloads

15,787

Version

1.2.12

License

MIT

Unpacked Size

6.51 kB

Total Files

9

Last publish

Collaborators

  • jill64