npm.io
0.3.1 • Published 2d ago

@swift-rust/font

Licence
MIT
Version
0.3.1
Deps
0
Size
1.1 MB
Vulns
0
Weekly
0
Stars
3

@swift-rust/font

The font component. Resolves Google Fonts and local fonts, generates className and CSS variable names that the bundler uses to wire up @font-face declarations at build time.

Usage

Google

import { Inter } from "swift-rust/font/google";

const inter = Inter({ subsets: ["latin"], display: "swap" });

export default function Layout({ children }: { children: React.ReactNode }) {
  return <html className={inter.className}><body>{children}</body></html>;
}

Or import from @swift-rust/font directly.

Local
import { localFont } from "swift-rust/font/local";
export const myFont = localFont({ src: "./fonts/MyFont.woff2" });
// then import it by name: import { myFont } from "./fonts";

The package also ships named local faces you can import directly, like Google fonts:

import { Lausanne, VarentGrotesk } from "swift-rust/font/local";

Available Google families

Inter, Roboto, Poppins, Manrope, IBM Plex Sans, JetBrains Mono. Add your own by exporting from @swift-rust/font/google.