| Crates.io | text_components |
| lib.rs | text_components |
| version | 0.1.6 |
| created_at | 2026-01-03 22:23:43.198846+00 |
| updated_at | 2026-01-24 17:41:43.637773+00 |
| description | A Rust implementation of Minecraft's Text Components |
| homepage | |
| repository | https://github.com/DarkMrMelther/text-components-rs |
| max_upload_size | |
| id | 2020878 |
| size | 238,465 |
This is a library for easy implementation and usage of Minecraft's Text Components, designed for Java edition but extensible to match Bedrock's Components.
You can make your first text component like this:
let component = TextComponent::plain("Hello World!");
Decorate it like this:
let component = component.color(Color::Red).bold(true);
Adding interactivility like this:
let component = component.insertion("Hello");
let component = component.hover_event(
HoverEvent::show_text("Hello World!")
);
let component = component.click_event(
ClickEvent::open_url("https://github.com/DarkMrMelther/text-components-rs")
);
Once the component is ready to be sent or displayed only rests building it:
component.build(resolutor, PrettyTextBuilder);
// Equivalent of doing:
component.to_pretty(resolutor);
If you want to use serde you will need to do this instead:
component.resolve(resolutor).serialize(serializer);
TextComponent implements Display for easy logging, as you can see, a component
needs to be resolved before building it into any format, by default it uses a static
reference to NoResolutor, but can be changed to a custom one with:
(Resolutor must be static, or made inside the function call)
set_display_resolutor(&Resolutor);
A text component can be printed like a string like this:
println!("{}", component);
// With format (pretty):
println!("{:p}", component);
To test the capabilities of the library you can execute:
cargo run --example main
With all the features:
cargo run --example main --features serde,nbt,custom