New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-dynamic-fonts

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dynamic-fonts

`react-dynamic-fonts` is a lightweight and flexible React library that allows you to dynamically change fonts in your React applications. With built-in support for Google Fonts, this package makes it easy to provide a seamless font-switching experience, e

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
0
Created
Source

React Dynamic Fonts

react-dynamic-fonts is a lightweight and flexible React library that allows you to dynamically change fonts in your React applications. With built-in support for Google Fonts, this package makes it easy to provide a seamless font-switching experience, enabling users to customize the typography of your app on the fly.

Features

  • Dynamic Font Switching: Easily switch between different fonts in your application with minimal configuration.
  • Google Fonts Integration: Out-of-the-box support for a wide array of Google Fonts.
  • Context API: Provides a simple and efficient way to manage font state across your application using React’s Context API.

Installation

npm install react-dynamic-fonts

or

pnpm add react-dynamic-fonts

Usage

Wrap your application in the FontProvider and use the useFont hook to manage and switch fonts dynamically:

import React from 'react';
import { FontProvider, useFont } from 'react-dynamic-fonts';

const App = () => {
  const { font, setFont, fonts } = useFont();

  return (
    <div>
      <h1 style={{ fontFamily: font }}>Hello, World!</h1>
      <select value={font} onChange={(e) => setFont(e.target.value)}>
        {fonts.map((f) => (
          <option key={f} value={f}>
            {f}
          </option>
        ))}
      </select>
    </div>
  );
};

export default function Root() {
  return (
    <FontProvider>
      <App />
    </FontProvider>
  );
}

Keywords

react

FAQs

Package last updated on 03 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts