If you’re using Plasmic global variants with PlasmicRootProvider and they aren’t applying even though you’re passing the correct value, the issue might be the
variant name casing.
The problem: Plasmic automatically capitalizes global variant group names. So even if you create a variant group called myVariant (camelCase) or locale
(lowercase), Plasmic stores it as MyVariant / Locale (capitalized).
The fix: Make sure the name in globalVariants uses the capitalized version:
// Won't work
globalVariants={[{ name: "locale", value: locale }]}
// Works
globalVariants={[{ name: "Locale", value: locale }]}
Full example with Next.js Pages Router and a locale variant:
export default function PlasmicLoaderPage(props) {
const { query, locale } = useRouter();
// ...
return (
<PlasmicRootProvider
loader={PLASMIC}
prefetchedData={plasmicData}
globalVariants={[{ name: "Locale", value: locale }]}
>
<PlasmicComponent component={pageMeta.displayName} />
</PlasmicRootProvider>
);
}
Feature request: Could the globalVariants name matching be made case-insensitive?
Hope this saves someone some debugging time!