Skip to main content

Story Props

When a Story's story property is a function, Flipbook calls it with a single StoryProps table containing the following.

PropertyTypeDescription
containerInstanceWhere the Story renders. Parent your UI here when you don't return it from the function.
controls{ [string]: any }The current value of each of the Story's Controls, keyed by control name. Changing a control re-renders the Story with the new values.
colorMode"Dark" | "Light"The color mode Flipbook is rendering with: Studio's theme, unless overridden in Settings. Use it to match your UI's colors to the canvas.
themeNamestringThe app theme Flipbook is rendering with, such as "Default" or "Kids". Matches Foundation's ThemeName enum. Set it in Settings.
theme"Dark" | "Light"Deprecated. Use colorMode instead.
localestringCurrently always "en-us".
pluginPluginlikeA wrapper around Flipbook's plugin instance. Its methods do nothing when Flipbook is embedded in an experience.
widgetGuiBase2dThe GUI hosting Flipbook's interface. Useful for mounting overlays, like popups and tooltips, that need to escape the Story's container.

This Story parents its UI to props.container instead of returning it, and returns a cleanup function that runs when the Story unmounts:

ButtonWithCleanup.story.luau
type Props = {
container: Instance,
}

return {
story = function(props: Props)
local button = Instance.new("TextButton")
button.Text = "Click Me"
button.TextSize = 16
button.Font = Enum.Font.BuilderSansExtraBold
button.TextColor3 = Color3.fromRGB(50, 50, 50)
button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
button.BorderSizePixel = 0
button.Size = UDim2.fromOffset(200, 40)
button.Parent = props.container

button.Activated:Connect(function()
print("clicked")
end)

return function()
button:Destroy()
end
end,
}

And this one reads props.controls to configure what it renders:

ButtonWithControls.story.luau
local controls = {
isDisabled = false,
}

type Props = {
controls: typeof(controls),
}

return {
controls = controls,
story = function(props: Props)
local button = Instance.new("TextButton")
button.Text = if props.controls.isDisabled then "Disabled" else "Click Me"
button.TextSize = 16
button.Font = Enum.Font.BuilderSansExtraBold
button.TextColor3 = Color3.fromRGB(50, 50, 50)
button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
button.AutoButtonColor = not props.controls.isDisabled
button.BorderSizePixel = 0
button.Size = UDim2.fromOffset(200, 40)

button.Activated:Connect(function()
if not props.controls.isDisabled then
print("clicked")
end
end)

return button
end,
}
note

Story Format: the full Story module API Controls · Writing Stories