Skip to main content

Roact

Flipbook supports Roblox's legacy Roact library. Pass in your installation of Roact to your Storybook and all stories will be rendered with it.

The Storybook and Story below are each shown in two forms, Default and Storyteller. See Frameworks for what sets them apart.

info

Roact is an archived repository that we consider to be legacy software. We recommend the use of React for new work. Flipbook aims to support Roact for the foreseeable future, but reserves the option to remove support in future major versions.

Storybook​

Default​

Roact.storybook.luau
local Roact = require("@pkg/Roact")

return {
name = "Roact",
storyRoots = {
script.Parent,
},
packages = {
Roact = Roact,
},
}

Storyteller​

Roact.storybook.luau
local Roact = require("@pkg/Roact")
local Storyteller = require("@pkg/Storyteller")

local storybook: Storyteller.Storybook = {
name = "Roact (Storyteller)",
storyRoots = {
script.Parent,
},
packages = {
Roact = Roact,
},
}

return storybook

Component​

RoactButton.luau
local Roact = require("@pkg/Roact")

local RoactButton = Roact.Component:extend("RoactButton")

function RoactButton:render()
return Roact.createElement("TextButton", {
Text = self.props.text,
TextSize = 16,
Font = Enum.Font.BuilderSansExtraBold,
TextColor3 = Color3.fromRGB(50, 50, 50),
BackgroundColor3 = Color3.fromRGB(255, 255, 255),
BorderSizePixel = 0,
Size = UDim2.fromOffset(200, 40),
[Roact.Event.Activated] = self.props.onActivated,
})
end

return RoactButton

Story​

Default​

RoactButton.story.luau
local Roact = require("@pkg/Roact")

local RoactButton = require("./RoactButton")

return {
story = function()
return Roact.createElement(RoactButton, {
text = "Click Me",
onActivated = function()
print("click")
end,
})
end,
}

Storyteller​

RoactButton.story.luau
local Roact = require("@pkg/Roact")
local Storyteller = require("@pkg/Storyteller")

local RoactButton = require("./RoactButton")

local story: Storyteller.Story<unknown> = {
story = function()
return Roact.createElement(RoactButton, {
text = "Click Me",
onActivated = function()
print("click")
end,
})
end,
}

return story