RichStylized - Create Rich Text from code

Rich Stylized

Hi, this is my first resource : RichStylized. RichStylized helps you create rich text from code. It’s a really light utils module, and in fact, it contains only one function.

The script is available here: Roblox Marketplace
and also on my github here.

So, how does it work?

It’s really simple. Let me show you an example first:

local RichStylized = require(script.RichStylized) -- require the library
local myTextLabel = script.Parent

myTextLabel.Text = RichStylized("I'm pink and I'm bold!", {
	font = {
		color = Color3.fromRGB(255, 29, 217)
	},
	bold = true
}).str

Result:
Capturdqzdqzdzqde

So, the module is just a function, where you put text as parameters and a table with the settings. But here, you can see the power of RichStylized because it supports the roblox objects (like Color3 for example). Also, make sure to put “.str” at the end. It won’t work otherwise.

But you can also combine different styles really easily:

myTextLabel.Text = RichStylized(
	"This is a random number: ", math.random(1, 50), "\nand this is ", 
	RichStylized("blue", {
		font = {
			color = Color3.fromRGB(101, 134, 255),
			face = Enum.Font.Code
		},
		stroke = {
			color = BrickColor.Black(),
			thickness = 4
		},
	}),
	"!",
	{
		font = {
			color = Color3.fromRGB(255, 108, 253)
		},
		bold = true
	}
).str

Result:
image

Ok, this one is a little bit more complicated. So first, we can see that we can concatenate strings and value:
"This is a random number: ", math.random(1, 50), "\nand this is "
But you can also add line break by simply adding \n

You can also concatenate RichStylized text together, without using .str. Here, you can see that we can edit the font family, but also add stroke. We can also use BrickColor instead of Color3,.

There is a lot of settings, which have mainly the same name as on this page: Rich Text Markup. Mostly all settings accept raw string value described in the roblox documentation page. So for instance, for the color of font, you can simply use the string "#AAFFAA" or "rgb(150,100,120"

Finally, I just want to add that there are some shortcuts, for example, instead of writting bold = true, you can write b = true, it’s the same. Also, the function automatically escapes characters like &, <, >, ’ and .

All Settings

RichStylized("All settings", {
	font = {
		color = Color3.fromRGB(255, 255, 0) or BrickColor.Yellow() or "FFFF00" or "rgb(255,255,0)",
		size = 36 or Enum.FontSize.Size36 or "36",
		face = Enum.Font.FredokaOne or "FredokaOne",
		weight = Enum.FontWeight.Bold or 700 or "Bold" or "700",
		transparency = 0.25 or "0.25"
	},
	
	stroke = {
		color = Color3.fromRGB(255, 255, 0) or BrickColor.Yellow() or "FFFF00" or "rgb(255,255,0)",
		joins = Enum.LineJoinMode.Miter or "miter",
		thickness = 4 or "4",
		transparency = 0.25 or "0.25"
	},
	
	bold = true, b = true,
	italic = true, i = true,
	underline = true, u = true,
	strikethrough = true, s = true,
	uppercase = true, uc = true,
	smallCaps = true, sc = true,
	
	autoEscapeChars = true -- by default, set to false if you don't want the function to escape chars.
})

Thank you for reading my post!

This is my first public resource. This isn’t amazing but I’m proud of it!

4 Likes

ok one thing that can make this go yes is add emojis and gifs!
I tried makng the thing similar to that but as you know ur not a dev until you know ctrl+c and ctrl+v so yoink.
Haha jokes aside thats really good! One thing you should try is making it a bit like the default roblox rich text thingy like requires only 1 string e.g

"<color=Medium Blue>The best blue color ever fr no joke<color>, **BOLD**, *ITALIC*, ~STRIKE~, _under_"

the color varaible needs brickcolor so like that.

1 Like

A mans first resource but a useful resource. Good job.

1 Like