JSPM

  • Created
  • Published
  • Downloads 79559
  • Score
    100M100P100Q200949F
  • License BSD-3-Clause

ANSI to React Elements

Package Exports

  • ansi-to-react

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ansi-to-react) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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