pesde goatsoft / lucy

IconStack

Several icons drawn as one. Repeat one icon to show how much of something there is, such as more hearts for a bigger shout out, or place different icons by hand, such as a small star on the corner of a gem. Each icon takes the theme's colours, like Icon.

IconStack exampleIconStack example
local function shoutOut(hearts, text)
    return Lucy.Stack.new({
        gap = "Space2",
        align = "center",
        size = UDim2.new(),
        automaticSize = Enum.AutomaticSize.XY,
        children = {
            Lucy.IconStack.new({
                icon = "lucide-extended:heart-filled",
                count = hearts,
                size = "xl",
                variant = "destructive",
                cutout = true,
            }),
            Lucy.Text.new({ text = text, variant = "muted", autoWidth = true }),
        },
    })
end

Lucy.Stack.new({
    direction = "horizontal",
    gap = "Space6",
    align = "end",
    children = {
        shoutOut(1, "Nice set"),
        shoutOut(3, "Floor filler"),
        shoutOut(5, "Legend"),
    },
    Parent = parent,
})

Arrangements

Give it an icon and a count, and arrange lays them out:

  • fan: the biggest in the middle and on top, each further out smaller, lower and tilted away, like a hand of cards.
  • row: all the same size in a line, each a little over the one before.
  • pile: rows that get shorter going up, with the bottom row in front.
IconStack exampleIconStack example
local function stars(arrange)
    return Lucy.IconStack.new({
        icon = "lucide-extended:star-filled",
        count = 4,
        arrange = arrange,
        size = "lg",
        variant = "warning",
        cutout = true,
    })
end

Lucy.Stack.new({
    direction = "horizontal",
    gap = "Space6",
    align = "center",
    children = { stars("fan"), stars("row"), stars("pile") },
    Parent = parent,
})

The stack is as big as its icons, so a layout around it gives the whole fan or pile its room.

Placing icons yourself

layers places each icon, and then count and arrange are not used. A layer names its own icon and variant, or takes the stack's.

IconStack exampleIconStack example
Lucy.IconStack.new({
    size = 48,
    layers = {
        { icon = "lucide-extended:gem-filled", variant = "primary" },
        {
            icon = "lucide-extended:star-filled",
            x = 0.4,
            y = 0.35,
            size = 0.45,
            rotation = 15,
            variant = "warning",
        },
    },
    cutout = true,
    Parent = parent,
})

Each layer takes:

FieldDefaultWhat it does
iconthe stack's iconWhat this layer draws
x, y0How far it sits from the middle, in icons: 0.5 is half an icon right (or down)
size1Its share of the stack's size: 1 is the full size, 0.5 half
rotation0How far it is turned, in degrees
variantthe stack's variantIts colour, as Icon's
z0Higher is in front. Layers with the same z go in the order listed, the last on top

Cutout

Where icons overlap, solid shapes of one colour run together. With cutout, each icon gets a thin ring in the colour under the stack, so it stands apart from the ones behind it. The ring takes the card colour. On another colour, give the ring that colour with a rule of your own, for a frame you have tagged shout-out:

app.theme:addRules("shoutOuts", {
    {
        selector = ".shout-out >> .ui-icon-stack-cutout",
        priority = 10,
        properties = { ImageColor3 = "$Primary" },
    },
})

Props

PropTypeDefaultState keyWhat it does
iconstring or number""yesThe icon every layer draws unless it names its own: a registered name, an asset id or a url
countnumber1yesHow many icons to arrange
arrangestring"fan"yesfan, row or pile
layerstablenoneyesPlaces each icon yourself (see above); count and arrange are then not used
sizestring or number"md"yesThe biggest icon: sm (16 pixels), md (20), lg (24), xl (28), or a number of pixels. A quarter larger on TV
variantstring"default"yesThe colour of every layer that names none, as Icon's
cutoutbooleanfalseyesA ring round each icon in the colour under the stack
visiblebooleantrueyesShows or hides it

It also takes the props every component takes.

Preview

In Studio, from the command bar: Lucy.Preview.show("IconStack").