-
Notifications
You must be signed in to change notification settings - Fork 0
text component
Andrey Vakhterov edited this page Feb 20, 2022
·
6 revisions
<text> Displays formatted text.
<text> can have the following properties (all optional)
| property | description | value | example |
|---|---|---|---|
| text | A string containing plain text to display directly | any text | <text text="hello world" /> |
| endl | Add line-break (\n) in the end of component |
true, false
|
<text endl="true">line</text> |
| bold | Whether to render the content in bold |
true, false
|
<text bold="true">bold text</text> |
| italic | Whether to render the content in italics |
true, false
|
<text italic="true">italic text</text> |
| underlined | Whether to underline the contents |
true, false
|
<text underlined="true">underlined text</text> |
| strikethrough | Whether to strikethrough the content |
true, false
|
<text strikethrough="true">strike</text> |
| obfuscated | Whether to render the content obfuscated |
true, false
|
<text obfuscated="true">You can not read this</text> |
| color | The color to render the content in |
black, dark_blue, dark_green, dark_aqua, dark_red, dark_purple, gold, gray, dark_gray, blue, green, aqua, red, light_purple, yellow, white, reset, or 6-digit hexadecimal color format #<hex>
|
<text color="#FF0000">this color is red</text> |
| font | Text font. See fandom wiki |
minecraft:default,minecraft:alt
|
<text font="minecraft:alt">alt font</text> |
| insertion | When the text is shift-clicked by a player, this string is inserted in their chat input. It does not overwrite any existing text the player was writing. This only works in chat messages. | any text | Player <text insertion="DPOHVAR">DPOHVAR</text> left the game |
| onclick | Allows for events to occur when the player clicks on text |
run:<command>, url:<url to open>, suggest:<command>, page:<page number>, copy:<text>, empty |
<text onclick="run:/reload">[reload the server]</text> |
Tag content can includes:
| component | description |
|---|---|
| raw text | Spaces and line breaks will collapse into a single space |
<pre> |
Text which is to be presented exactly as written inside <pre>. No other tags allowed inside |
<br/> |
Add a line break in text (carriage-return) |
<space/> |
Add a space |
<text> |
See text component |
<keybind> |
See keybind component |
<score> |
See score component |
<keybind> |
See keybind component |
<translatable> |
See translatable component |
<selector> |
See selector component |
<hover-text> |
Hover event. See hover-text tag |
<hover-item> |
Hover event. See hover-item tag |
<hover-entity> |
Hover event. See hover-entity tag |
Only one hover event is allowed per content. Hover event can be placed only at the end of the content.
What the difference between
<text text="value"/>and<text>value<text>?
No difference in this case. But "text" property can includes multiple spaces in a row that won't collapse
I got extra spaces in the formatted text:
<text underlined="true">
underlined text
</text>wrap your text with <pre>
<text underlined="true">
<pre>underlined text</pre>
</text>