Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-dynamic-font

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dynamic-font

make your text does not wrap and dynamically adjust the font size

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
688
decreased by-14.53%
Maintainers
1
Weekly downloads
 
Created
Source

react-dynamic-font

This is a react component which made your text does not wrap and dynamically adjust the font size

Sometimes we want some text to have a fixed width, and it will automatically reducing the font size when the number of characters is too large, so that the text is always in one line without wrapping. This is why I created this component.

Demo

Installation

npm install react-dynamic-font --save

or

yarn add react-dynamic-font

Usage

ReactDynamicFont use the width of its parent element as the fixed width, and remember to add the css style overflow: hidden to its parent element.

import React, { Component } from 'react';
import DynamicFont from 'react-dynamic-font';

class Demo extends Component {
  render() {
    const style = {
      width: 400,
      fontSize: 30,
      lineHeight: 30,
      overflow: 'hidden',
    };
    return (
      <div style={{style}}>
        <DynamicFont content={/* Your text here */} />
      </div>
    );
  }
}

If you want to add smooth animate while font-size changing, add the smooth props.

<DynamicFont smooth content={/* Your text here */} />

Have fun!

Keywords

FAQs

Package last updated on 25 Oct 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc