富文本標記

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

UI 富文本 利用簡單的標記標籤來樣式化字串的部分,包括粗體、斜體、下劃線、填充顏色、描邊變化等。您可以將樣式標籤應用於 TextLabelTextButtonTextBox 物件。

啟用富文本

您必須通過其 RichText 屬性在每個物件上啟用富文本,這可以在 屬性 窗口中進行,或通過在 LocalScript 中將屬性設置為 true

local title = Instance.new("TextLabel")
title.RichText = true
title.Text = "使用 <b>粗體標題</b>"

支持的標籤

富文本標籤類似於 XML/HTML 標籤,您必須在格式化文本周圍包含開啟和關閉標籤。

<b>格式化文本</b>

您也可以將標籤嵌套在一起,只要您以相反的順序關閉它們。

<b><i><u>格式化文本</u></i></b>

字體顏色

<font color=""> </font>

我想要 <font color="#FF7800">橙色</font> 糖果。
我想要 <font color="rgb(255,125,0)">橙色</font> 糖果。

字體大小

<font size=""> </font>

<font size="40">這是大字。</font> <font size="20">這是小字。</font>

字體樣式

<font face=""> </font>

<font face="Michroma">這是 Michroma 字體。</font>

字體家族

<font family=""> </font>

<font family="rbxasset://fonts/families/Michroma.json">這是 Michroma 字體。</font>

字體粗細

<font weight=""> </font>

這是正常的。 <font weight="heavy">這是粗的。</font>
這是正常的。 <font weight="900">這是粗的。</font>

字體透明度

<font transparency=""> </font>

文本在 <font transparency="0.5">50% 透明度</font>。

描邊

<stroke> </stroke>

參數等效屬性示例值
colorUIStroke.Color"rgb(255,125,0)""#FF7800"
thicknessthUIStroke.Thickness"1""4""0.5"
transparencytrUIStroke.Transparency"0""0.5""1"
joinsUIStroke.LineJoinMode"round""bevel""miter"
sizingUIStroke.StrokeSizingMode"fixed""scaled"

您贏得了 <stroke color="#00A2FF" thickness="2" transparency="0.25" joins="miter">25 顆寶石</stroke>。

粗體

<b> </b>

文本為 <b>粗體</b>。

斜體

<i> </i>

文本 <i>斜體</i>。

下劃線

<u> </u>

文本 <u>下劃線</u>。

刪除線

<s> </s>

文本帶有 <s>刪除線</s>。

換行

<br/>

這句話之後會換行。<br/>下一句...

大寫

<uppercase> </uppercase>
<uc> </uc>

<uppercase>大寫</uppercase> 使單詞讀起來響亮!
<uc>大寫</uc> 使單詞讀起來響亮!

小型大寫

<smallcaps> </smallcaps>
<sc> </sc>

我的名字是 <smallcaps>Diva Dragonslayer</smallcaps>。
我的名字是 <sc>Diva Dragonslayer</sc>。

標記

<mark> </mark>

文本 <mark color="#009966" transparency="0">高亮顯示</mark>。

註解

<!-- -->

這之後是註解...<!--這不會出現在最終文本中--> 現在有更多文本...

轉義形式

如果您想渲染某些字符,如 <>,並將它們排除在富文本標籤之外,您可以將它們寫成 轉義形式

字符轉義示例結果
<&lt;10 &lt; 10010 < 100
>&gt;100 &gt; 10100 > 10
"&quot;Meet &quot;Diva Dragonslayer&quot;Meet "Diva Dragonslayer"
'&apos;Diva&apos;s pet is a falcon!Diva's pet is a falcon!
&&amp;Render another escape form <b>&amp;lt;</b> by escaping an ampersandRender another escape form &lt; by escaping an ampersand
©2026 Roblox Corporation、Roblox、Roblox 標誌及 Powering Imagination 是我們在美國及其他國家地區的部分註冊與未註冊商標。