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

react-ascii-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-ascii-text

React hook to render and animate ASCII text art

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React ASCII Text

This library provides a React hook to render or animate ASCII text art using Figlet fonts.

DEMO

Installation

npm install react-ascii-text

Usage

Figlet fonts are included in the package and can be imported. Full list of fonts along with UI to try them out can be found here.

Note that the font names are converted to camelCasing, omitting spaces and hyphens to allow use as ES modules. This is to allow dynamic import of font and bundlers to only include the desired one in your project code.

Font nameImport
1Rowimport { oneRow } from 'react-ascii-text
3-Dimport { threeD } from 'react-ascii-text'
5 Line Obliqueimport { fiveLineOblique } from 'react-ascii-text'
Big Money-swimport { bigMoneySw } from 'react-ascii-text'
etc.

Render ASCII text

Passing a single string will render the text in a Figlet font.

import { useAsciiText, alligator } from 'react-ascii-text';

function MyComponent() {
  const asciiTextRef = useAsciiText({
    font: alligator,
    text: "Hello, World!",
  });

  return <pre ref={asciiTextRef}></pre>;
}

Animate ASCII text

Pass an array of strings to animate a transition between them.

import { useAsciiText, alligator } from 'react-ascii-text';

function MyComponent() {
  const asciiTextRef = useAsciiText({
    animationCharacters: "▒░█",
    animationCharacterSpacing: 1,
    animationDelay: 2000,
    animationDirection: "down",
    animationInterval: 100,
    animationLoop: true,
    animationSpeed: 30,
    font: alligator,
    text: ["REACT", "ASCII", "TEXT"],
  });

  return <pre ref={asciiTextRef}></pre>;
}

Parameters

  • animationDirection (optional, default: "horizontal"): Specifies the direction of the text animation. Possible are "down", "up", "left", "right", "horizontal", and "vertical".
  • animationCharacters (optional, default: '0123456789'): Characters that replace the rendered text in the animation.
  • animationCharacterSpacing (optional, default: 1): The spacing between animation characters.
  • animationDelay (optional, default: 500): The delay before the animation starts in ms.
  • animationInterval (optional, default: 1000): The interval (in milliseconds) between animations.
  • animationIteration (optional, default: 1): The number of times the animation should repeat.
  • animationLoop (optional, default: true): Whether the animation should loop indefinitely.
  • animationSpeed (optional, default: 20): The speed of the animation, affecting how quickly frames transition.
  • fadeInOnly (optional, default: false): Whether the animation should only fade in.
  • fadeOutOnly (optional, default: false): Whether the animation should only fade out.
  • font (optional, default: Slant): The font to be used for rendering the ASCII text.
  • isAnimated (optional, default: true): Whether the text should be animated.
  • isPaused (optional, default: false): Determines whether the animation is initially paused.
  • text (optional, default: ["React", "ASCII", "Text"]): The ASCII text to be animated. It can be a single string or an array of strings to transition animations between strings.

License

MIT

Keywords

FAQs

Package last updated on 12 Feb 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

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