@lattice-ui/style Part of the stable direction toward v1.0.
What It Is For
Use @lattice-ui/style as the default baseline for product UI styling in Lattice UI apps.
It provides theme tokens, primitive text/box helpers, sx composition, and reusable recipes without dictating app structure.
import {
createRecipe,
defaultDarkTheme,
mergeGuiProps,
Text,
ThemeProvider,
useTheme,
} from "@lattice-ui/style";
type GuiProps = Record<string, unknown>;
const panelRecipe = createRecipe<GuiProps, {}>({
base: (theme) => ({
BackgroundColor3: theme.colors.surface,
BorderSizePixel: 0,
}),
});
function StyleDemo() {
const { theme } = useTheme();
return (
<frame BackgroundTransparency={1} Size={UDim2.fromOffset(420, 220)}>
<frame
{...(mergeGuiProps(panelRecipe({}, theme), {
Size: UDim2.fromOffset(320, 160),
}) as Record<string, unknown>)}
>
<uicorner CornerRadius={new UDim(0, theme.radius.lg)} />
<Text
BackgroundTransparency={1}
Position={UDim2.fromOffset(theme.space[12], theme.space[12])}
Size={UDim2.fromOffset(280, 40)}
Text="Style keeps tokens, recipes, and text primitives in one place."
TextColor3={theme.colors.textPrimary}
TextSize={theme.typography.bodyMd.textSize}
TextWrapped={true}
TextXAlignment={Enum.TextXAlignment.Left}
TextYAlignment={Enum.TextYAlignment.Top}
/>
</frame>
</frame>
);
}
export function StyleExample() {
return (
<ThemeProvider defaultTheme={defaultDarkTheme}>
<StyleDemo />
</ThemeProvider>
);
} Live demo is experimental and may contain bugs.
Install
Global CLI command: lattice add style
Monorepo local script
Use your package manager wrapper when running the local lattice command.
pnpm lattice add stylePublic Exports
-
Box -
Text -
createRecipe -
mergeGuiProps -
mergeSx -
resolveSx -
ThemeProvider -
useTheme -
useThemeValue -
createTheme -
defaultDarkTheme -
defaultLightTheme
State Model
ThemeProviderowns the current theme object and exposes it throughuseThemeanduseThemeValue.createRecipeandmergeSxare pure style composition tools; they do not create runtime state on their own.- Theme tokens cover colors, spacing, radius, and typography, and other packages read from that theme model rather than duplicating scales.
Key API
ThemeProvider
Use theme, defaultTheme, and onThemeChange when your app needs controlled or uncontrolled theme ownership.
createRecipe
Use recipes to centralize visual variants instead of scattering conditional prop objects across your UI.
mergeGuiProps
Use this to layer base, variant, and caller overrides while composing Event and Change handlers instead of replacing them.
Box / Text
Use primitives for token-driven structure and typography without reaching directly for raw Roblox hosts everywhere.
Composition Patterns
Theme-backed product surfaces
Define recipes once, then apply them across buttons, panels, and labels so visual language stays coherent.
Custom component skins
Pair useTheme with headless packages like TextField or Select so semantics and visuals stay decoupled.
Cautions / Limits
stylehandles visual language, not app-level layout or density orchestration; usesystemfor that layer.- If you bypass tokens with one-off values everywhere, the package stops paying for itself quickly.