Rich Text styling done right
- Expressive API
- Highly performant
- No dependencies
- Ability to nest styles
- Auto-detects color support
- Clean and focused
- Actively maintained
- Extremely Lightweight (less than 250 lines)
-- Run in Roblox Studio Console
local HttpService = game:GetService("HttpService");
local ReplicatedStorage = game:GetService("ReplicatedStorage");
HttpService.HttpEnabled = true
local ChalkModule = Instance.new("ModuleScript");
ChalkModule.Name = "Chalk";
ChalkModule.Parent = ReplicatedStorage;
local Request = HttpService:RequestAsync({
Url = "https://raw.githubusercontent.com/Perthys/chalk/main/source/main.lua";
Method = "GET";
});
if Request.Success and Request.StatusCode == 200 then
ChalkModule.Source = Request.Body
print("Successfully installed Chalk module. At:", ChalkModule);
else
error("Failed to install Chalk module.");
end
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local Chalk = require(ReplicatedStorage:WaitForChild("Chalk"));
local TextBox = script.Parent;
TextBox.Text = chalk.blue('Hello world!')
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local Chalk = require(ReplicatedStorage:WaitForChild("Chalk"));
local TextBox = script.Parent;
TextBox.Text = Chalk.blue("Hello") .. 'World' .. chalk.red("!")
TextBox.Text = Chalk.blue.bold("Hello world!")
TextBox.Text = Chalk.blue("Hello", "World!", "Foo", "bar", "biz", "baz")
TextBox.Text = Chalk.red("Hello", Chalk.underline("world") .. "!")
TextBox.Text = Chalk.green(
"I am a green line " ..
Chalk.blue.underline.bold("with a blue substring") ..
" that becomes green again!"
)
TextBox.Text = ([[
CPU: %s
RAM: %s
DISK: %s
]]):format(
Chalk.red("90%"),
Chalk.green("40%"),
Chalk.yellow("70%")
)
TextBox.Text = Chalk.color(123, 45, 67).underline("Underlined reddish color")
TextBox.Text = Chalk.color("#DEADED").bold("Bold gray!")
Easily define your own themes:
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local Chalk = require(ReplicatedStorage:WaitForChild("Chalk"));
local TextBox = script.Parent;
local error = Chalk.bold.red;
local warning = Chalk.color("#FFA500");
TextBox.Text = error("Error!")
TextBox.Text = warning("Warning!");
Take advantage of string substitution:
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local Chalk = require(ReplicatedStorage:WaitForChild("Chalk"));
local TextBox = script.Parent;
local Name = "Sindre";
TextBox.Text = Chalk.green(("%s"):format(Name))
Example: chalk.red.bold.underline('Hello', 'world');
Chain styles and call the last one as a method with a string argument. Order doesn't matter, and earlier styles take precedent in case of a conflict. This simply means that chalk.red.yellow.green
is equivalent to chalk.red
.
-
Chalk.[<BrickColorName>]
- Index a BrickColor -
Chalk.bold
- Make the text bold -
Chalk.italic
- Make the text italic -
Chalk.underline
- Underline the text -
Chalk.strikethrough
- Strike through the text -
Chalk.uppercase
- Convert text to uppercase -
Chalk.smallcaps
- Convert text to small capitals -
Chalk.color(Hex) | Chalk.color(R, G, B) | Chalk.color(Color3.new())
- Set the color -
Chalk.size([<Size>])
- Set the size of the text (Number) -
Chalk.face([<Face>])
- Set the typeface of the text (String) -
Chalk.family([<rbxasset://>])
- Set the font family from an asset (String) -
Chalk.weight([<Weight>])
- Set the font weight (String) -
Chalk.transparency([<Transparency>])
- Set the transparency of the text (Number 0-1) -
Chalk.stroke({Color = [<Color>], Joins = [<Joins>], Thickness = [<Thickness>], Transparency = [<Transparency>]})
- Define stroke properties: color (Color3), joins (String), thickness (Number), and transparency (Number)
All BrickColor
Colors
Chalk.white
- Set the color to whiteChalk.black
- Set the color to blackChalk.red
- Set the color to redChalk.brown
- Set the color to brownChalk.orange
- Set the color to orangeChalk.yellow
- Set the color to yellowChalk.lime
- Set the color to limeChalk.green
- Set the color to greenChalk.blue
- Set the color to blueChalk.purple
- Set the color to purpleChalk.pink
- Set the color to pink
Chalk supports Color3 and hex colors.
Examples:
chalk.color('#DEADED').underline('Hello, world!')
chalk.color(15, 100, 204)
The following color models can be used:
rgb
- Example:chalk.color(255, 136, 0).bold('Orange!')
hex
- Example:chalk.color('#FF8800').bold('Orange!')
Literally made the npm package
but for roblox luau richtext
Cause I really did not want to do styling manually.
ROBLOX PLEASE ADD CONSOLE STYLING I KNOW ITS POSSIBLE JUST ENABLE RICH TEXT
If roblox adds support for background text directly with richtext i will also add support
- Perth |
Perthys#0