Skip to content

Text

Text in the theme’s fonts and colours: headings, body copy, muted notes and labels. It wraps to fill its parent’s width unless you ask it to fit the text. handle.Instance is the TextLabel.

Text exampleText example
Lucy.Stack.new({
    gap = "Space1",
    children = {
        Lucy.Text.new({ text = "Club Lucy", variant = "h1", align = "center" }),
        Lucy.Text.new({ text = "DJ Lucy is on the decks tonight", variant = "lead", align = "center" }),
        Lucy.Text.new({ text = "Now playing: Neon Nights, 124 BPM", variant = "muted", align = "center" }),
    },
    Parent = parent,
})

Props

PropTypeDefaultState keyWhat it does
textstring""yesThe text
variantstring"p"yesThe style, see below
alignstring"left"yesleft, center or right
visiblebooleantrueyesShows or hides it
autoWidthboolean or responsivefalseSizes to the text instead of filling the width, and stops wrapping
wrapboolean, responsive or getterfalse keeps the text on one line, true wraps it. Left out, text that fills the width wraps and text sized to its words (autoWidth, reserve) does not
fittrue or numberKeeps the text on one line, sized to its words, and scales it down when it is wider than its parent has room for, never under 0.6 of its size. A number sets that floor instead (fit = 0.5)
reservestring or getterHolds the width of the widest text of this shape, so a timer or count never moves what is around it: "0:00" holds the widest time with any digits. Measured in the text’s own font and size. Align it to say which side the number keeps to. Give a getter for a line whose words change too (return the line itself): it holds the widest for those words and only moves when the words do
richTextbooleanfalseTurns on Roblox rich text tags such as <b>
revealnumber or trueTypes the text out, this many characters a second (true: 40), and again from the start whenever the text changes
revealingbooleanfalseyes, read onlyWhether it is typing out now
valuenumberyesShows this number instead of text, formatted by format
formatfunctionLucy.Format.numberTurns value into text, such as function(n) return `+{n} XP` end
countnumber or trueCounts up to value over this many seconds (true: 0.8), and on from where it is when it changes
fromnumber0Where the first count starts
countingbooleanfalseyes, read onlyWhether it is counting now

It also takes the props every component takes.

VariantUse it for
h1 to h4Headings, largest first
pBody text
leadA larger, softer opening line
largeText that should stand out
smallSmall print
mutedNotes and hints, in a softer colour
labelLabels for fields and settings

Examples

A label that follows game state:

Text exampleText example
local coins = app.state:ref("player.coins")

Lucy.Text.new({
    text = function() return `Coins: {coins()}` end,
    variant = "h3",
    Parent = hud,
})

Text that fits itself, for use in a row:

Text exampleText example
Lucy.Text.new({ text = "Level 12", variant = "small", autoWidth = true, Parent = row })

A word or a stat that must stay on one line in a narrow card. With fit it shrinks to the card’s width instead of breaking over two lines or running out of the card, and keeps its own size whenever there is room. It measures against its parent, so put it straight in the card or row whose width it should keep to:

Text exampleText example
local card = Lucy.new "Frame" {
    Size = UDim2.fromOffset(110, 60),
    BackgroundTransparency = 1,
    Parent = parent,
}
Lucy.Text.new({ text = "OVERDRIVE", variant = "h2", fit = true, Parent = card })

Rich text:

Text exampleText example
Lucy.Text.new({ text = "Press <b>E</b> to dance", richText = true, Parent = prompt })

Text that types itself out, as a character’s line in a dialogue box. The whole line is laid out from the start, so words never jump to the next line as they appear. text:skipReveal() shows the rest at once (a press to skip ahead), and text.Revealed fires once it is all out:

local line = Lucy.Text.new({
    text = function() return speech() end,
    variant = "lead",
    reveal = 34,
    Parent = dialogue,
})
line.Revealed:Connect(function()
    nextButton:set("visible", true)
end)

A number that counts up to its value, such as XP on a results screen. It counts on from where it is whenever the value changes, so a second reward adds to the first. text:skipCount() lands it at once, and text.Counted fires when it lands:

local xp = app.state:ref("player.xp")

Lucy.Text.new({
    value = xp,
    count = true,
    format = function(n)
        return `{Lucy.Format.number(n)} XP`
    end,
    variant = "h2",
    Parent = results,
})

Both are composables underneath, useReveal and useCount, so anything else can type out or count up the same way.

Preview

In Studio, from the command bar: Lucy.Preview.show("Text"), and Lucy.Preview.show("TextMotion") for the reveal and the count.