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

react-controlled-text

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-controlled-text

Multiline text clamp and scale to fit component for React ⚛️

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-controlled-text · downloads version code style: prettier

Multiline text clamp and scale to fit component for React ⚛️

Available features

  • Resize text to fit within a container
  • Multiline text clamp

Both features are enabled by default (see props below).

Example

Example

Demo

Storybook (https://gr34se.github.io/react-controlled-text)

Usage

import ControlledText from "react-controlled-text";
<div style={{backgroundColor: "lightgreen", width: 200, height: 80, padding: 2}}>
    <ControlledText fontSizeMin={12} fontSizeMax={15} clampSuffix={"..."}>
        Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum
        has been the industry's standard dummy text ever since the 1500s, when an unknown
        printer took a galley of, type and scrambled it to make a type specimen book.
    </ControlledText>
</div>

Props

Prop nameTypeDefaultRequiredNote
fontSizeMinnumber10noMinimum font size
fontSizeMaxnumber16noMaximum font size
classNamestring"react-controlled-text"noclassName that output tag will receive
tagNameTagName (string)"span"noOne of: span, div, p, a, h1, h2, h3, h4, h5, h6
resizeThrottlenumber250noNumber of milliseconds to throttle window resize callback
clampSuffixstring"..."noString to add at the end of clamped text
disableScalingbooleanfalsenoProp to disable auto-scaling
disableTextClampbooleanfalsenoProp to disable auto-text-clamping if needed

You can also pass other common HTML props (HTMLAttributes) such as onClick directly to the ControlledText component.

Keywords

FAQs

Package last updated on 08 Aug 2021

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