Story
A Story renders a piece of UI on its own, in a sandboxed canvas. It's lifted out of your game so you can build and review it without running the whole experience to reach the screen it lives on.
Concretely, a Story is a ModuleScript with a .story extension that returns a table with a story function. Flipbook calls that function to mount the UI into the canvas, then tears it down when you navigate away:
return {
story = function()
local button = Instance.new("TextButton")
button.Text = "Button"
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.Activated:Connect(function()
print("clicked")
end)
return button
end,
}
This Story uses Flipbook's built-in function-based renderer: it builds a TextButton and returns it. Because you hand back the Instance, Flipbook owns its lifecycle and cleans it up so you don't leak instances while iterating.
When you need to manage the UI lifecycle yourself (for example, to parent instances to a specific location or to clean up connections on unmount), the story function can instead parent the UI to props.container and return a cleanup callback:
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,
}
The legacy Hoarcekat shape, where the whole module is a function(container) that returns its own cleanup, is supported too. To render with a UI library instead, the same story function can return a React, Fusion, or Roact element; see Writing Stories for wiring one up.
The Canvas
Each Story renders into its own sandboxed canvas, isolated from the rest of your game. In a running experience a given piece of UI might only surface after a particular sequence of states (a panel that appears once its data has loaded, say), and reproducing that by hand on every edit is slow. The canvas lets you render that state directly and interact with it in place.
The canvas is closer to a Figma and Storybook hybrid than to a single fixed component. Today it renders a single Story, but it's built to grow toward multi-story views and documentation living alongside the live preview.
When you open a Story, Flipbook:
- Loads the module fresh through ModuleLoader, bypassing Roblox's
requirecache so that editing the Story hot-reloads its preview without restarting the plugin. - Calls the
storyfunction with a StoryProps object: the render container, the current controls, the Studio theme, and more. - Renders whatever the function returns into the canvas, and tears it down when you navigate away.
That fresh-load step is the reason saving a Story updates its preview instantly.
Stories Without a Storybook
A Story needs a Storybook to render. The Storybook's storyRoots tell Flipbook where to look for Stories. A Story that no Storybook covers still appears in the tree, under an "Unknown Stories" folder, but Flipbook won't preview it until a Storybook covers it.
The harder hurdle is getting the module shape right. Storyteller validates the returned table when it loads a Story and raises a "Story is malformed" error if it doesn't match, but there's no static typechecking to catch a missing story function or a misplaced field as you write, so a mistake tends to surface only when you open the Story. Typechecking with Storyteller's types is how you get ahead of it.
Story Format: the full module API Storybook · Writing Stories