# react-unity-rich-text

> React component to parse and stylize unity rich text

Latest version **1.1.0** (published 2018-11-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-unity-rich-text
pnpm add react-unity-rich-text
yarn add react-unity-rich-text
bun add react-unity-rich-text
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2018-11-12 |
| First published | 2018-11-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 1 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | emargollo |
| Maintainers | emargollo |

## Links

- npm: https://www.npmjs.com/package/react-unity-rich-text
- Repository: https://github.com/emargollo/react-unity-rich-text
- Homepage: https://github.com/emargollo/react-unity-rich-text#readme
- Issues: https://github.com/emargollo/react-unity-rich-text/issues
- npm.io page: https://npm.io/package/react-unity-rich-text

## Dependencies (1)

- [xml-js](https://npm.io/package/xml-js.md) ^1.6.8

## Recent versions

- 1.1.0 (latest) — 2018-11-12
- 1.0.1 — 2018-11-11
- 1.0.0 — 2018-11-11

## README

# react-unity-rich-text

> React component to parse and stylize unity rich text

[![NPM](https://img.shields.io/npm/v/react-unity-rich-text.svg)](https://www.npmjs.com/package/react-unity-rich-text) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

[![Demo](https://raw.githubusercontent.com/emargollo/react-unity-rich-text/master/example/demo.gif)](https://emargollo.github.io/react-unity-rich-text/)

This component can be used to render [Unity's Rich Text](https://docs.unity3d.com/Manual/StyledText.html) in the webpage by creating `span` tags with the appropriate styling.

## Install

```bash
npm install --save react-unity-rich-text
```

## Usage

Check out the [demo](https://emargollo.github.io/react-unity-rich-text/)

```jsx
import React, { Component } from 'react'

import UnityRichTextComponent from 'react-unity-rich-text'

class Example extends Component {
  render () {
    return (
      <UnityRichTextComponent>
        {"<size=30>Some unity <color=#ff0000ff>RICH</color> text</size>"}
      <UnityRichTextComponent>
    )
  }
}
```

## Unity Rich Text

(adapted from the [official documentation](https://docs.unity3d.com/Manual/StyledText.html))

### Supported tags

The following list describes all the styling tags supported by Unity.

| Tag | Description | Example |
|:----|:------------|:--------|
|b 	  | Renders the text in boldface. | `We are <b>not</b> amused.` |
|i    | Renders the text in italics.  | `We are <i>usually</i> not amused.` |
|size |	Sets the size of the text according to the parameter value, given in pixels. |	   `We are <size=50>largely</size> unaffected.`
|color |	Sets the color of the text according to the parameter value. The color can be specified in the traditional HTML format. #rrggbbaa or by using the default colors seen in the documentation |  `<color=#00ffffff>…</color>`

## Props

The Unity Rich Text Component can receive functions as props to handle the styling of the `span` for each kind of supported tag. All of these must be functions that return a [**react style**](https://reactjs.org/docs/dom-elements.html#style).

| Property | Parameters | Default return                  |
|:---------|:-----------|:--------------------------------|
| onBold   |            | `{fontWeight: 'bold'}`          |
| onItalic |            | `{fontStyle: 'italic'}`         |
| onSize   | size       | ```{fontSize: \`${size}px\`}``` |
| onColor  | color      | `{color: color}`                |

## License

MIT © [emargollo](https://github.com/emargollo)

---
_Source: https://npm.io/package/react-unity-rich-text · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
