npm

Check out our latest tech talk, "JavaScript Supply Chain Security" presented by VP of Security, Adam Baldwin.Watch it here »

ansi-to-react

5.0.0 • Public • Published

ansi-to-react

This package convert ANSI escape codes to formatted text output for React.

Installation

$ yarn add ansi-to-react
$ npm install --save ansi-to-react

Usage

Basic

The example below shows how we can use this package to render a string with ANSI escape codes.

import Ansi from "ansi-to-react";
 
export function () => {
  return <Ansi>
    {'\u001b[34mhello world'}
  </Ansi>;
};

Will render

<code>
    <span style="color:rgb(0, 0, 187)">hello world</span>
</code>

Classes

Style with classes instead of style attribute.

<Ansi useClasses>
    {'\u001b[34mhello world'}
</Ansi>;

Will render

<code>
    <span class="ansi-blue">hello world</span>
</code>

Class Names

Font color Background Color
ansi-black ansi-bright-black
ansi-red ansi-bright-red
ansi-green ansi-bright-green
ansi-yellow ansi-bright-yellow
ansi-blue ansi-bright-blue
ansi-magenta ansi-bright-magenta
ansi-cyan ansi-bright-cyan
ansi-white ansi-bright-white

Documentation

We're working on adding more documentation for this component. Stay tuned by watching this repository!

Support

If you experience an issue while using this package or have a feature request, please file an issue on the issue board and add the pkg:ansi-to-react label.

License

BSD-3-Clause

Keywords

install

npm i ansi-to-react

Downloadsweekly downloads

15,610

version

5.0.0

license

BSD-3-Clause

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
  • avatar
Report a vulnerability