1.0.0 • Published 12 months ago

use-font v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

use-font

Web Component for declarative font loading in Shadow DOM.

How to use

Import the component using your CDN of choice or from npm, and then include the component in any Shadow DOM.

<script type="module" src="https://unpkg.com/use-font@1"></script>

<cursive-text>
  <template shadowrootmode="open">
    <use-font href="https://fonts.googleapis.com/css2?family=Playwrite+CU"></use-font>
    <style>
      slot {
        font-family: 'Playwrite CU';
      }
    </style>

    <slot></slot>
  </template>

  very mindful, very demure
</cursive-text>

Why?

There are browser inconsistencies when loading fonts in Shadow DOM, so this provides a temporary resolution. See:

1.0.0

12 months ago