Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(styles): support scoped styles #350

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

metonym
Copy link
Owner

@metonym metonym commented Oct 5, 2024

Alternative to #349 that uses component composition.

<script lang="ts">
  import { Highlight, ScopedStyle } from "svelte-highlight";
  import typescript from "svelte-highlight/languages/typescript";
  import atomOneDark from "svelte-highlight/styles/atom-one-dark.scoped";
  import github from "svelte-highlight/styles/github.scoped";
  import blackMetalDarkFuneral from "svelte-highlight/styles/black-metal-dark-funeral.scoped";

  const code = "const add = (a: number, b: number) => a + b;";
</script>

<ScopedStyle {...atomOneDark}>
  <Highlight language={typescript} {code} />
</ScopedStyle>

<ScopedStyle {...github}>
  <Highlight language={typescript} {code} />
</ScopedStyle>

<ScopedStyle {...blackMetalDarkFuneral}>
  <Highlight language={typescript} {code} />
</ScopedStyle>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant