mctext-react
v1.1.0
Published
A React component to display Minecraft-formatted text.
Downloads
139
Readme
mctext-react
This library allows you to display text with Minecraft formatting. It supports JSON (component-based) text as well as strings with formatting codes.
Obfuscated text is also supported and will behave as it does ingame.
Installation
npm i --save mctext-react
Usage
import McText from 'mctext-react'
<McText>§4red §lbold red §r§kobfuscated</McText>
<McText>
{{
text: '',
extra: [
{
text: 'red ',
color: 'dark_red'
},
{
text: 'bold red ',
bold: true,
color: 'dark_red'
},
{
text: 'obfuscated',
obfuscated: true
}
]
}}
</McText>
Properties
| Name | Type | Default | Description |
| --- | --- | --- | --- |
| children * | string
or object
| | The text to display, see above. |
| colormap | object
| see below | An alternate colormap used to map Minecraft colors to CSS colors. |
| randomChars | string
| A…Za…z0…9!§$%&?#
| Characters to use for obfuscated text. |
| prefix | string
| §
| Character to use for color prefix, usually §
or &
. |
| style | object
| | Override the style of the text. |
* required property
Colormap
The sixteen Minecraft colors are mapped to CSS colors by using a colormap. The default colormap uses the colors from the Minecraft Wiki.
Related projects
- McTextBlock is a WPF component that displays Minecraft formatted text. It only supports strings with formatting codes.
License
The files included in this repository are licensed under the MIT license.