\n\n \n ```\n\n \n \n ```svelte fileName=\"Hero.svelte\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\n \n\n
\n

{$content.headline}

\n {$content.cta}\n
\n ```\n\n
\n \n ```tsx fileName=\"Hero.tsx\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\n import { useIntlayer } from \"preact-intlayer\";\n\n export const Hero = () => {\n const { headline, cta } = useIntlayer(\"hero-banner\");\n // → default variant\n\n return (\n
\n

{headline}

\n {cta}\n
\n );\n };\n ```\n\n
\n \n ```tsx fileName=\"Hero.tsx\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\n import { useIntlayer } from \"solid-intlayer\";\n\n export const Hero = () => {\n const content = useIntlayer(\"hero-banner\");\n // → default variant\n\n return (\n
\n

{content().headline}

\n {content().cta}\n
\n );\n };\n ```\n\n
\n \n ```typescript fileName=\"hero.component.ts\" contentDeclarationFormat={[\"typescript\", \"esm\", \"commonjs\"]}\n import { Component } from \"@angular/core\";\n import { useIntlayer } from \"angular-intlayer\";\n\n @Component({\n selector: \"app-hero\",\n template: `\n
\n

{{ content().headline }}

\n {{ content().cta }}\n
\n `,\n })\n export class HeroComponent {\n content = useIntlayer(\"hero-banner\");\n }\n ```\n\n
\n \n ```javascript fileName=\"hero.js\"\n import { useIntlayer } from \"vanilla-intlayer\";\n\n const { headline, cta } = useIntlayer(\"hero-banner\");\n\n document.body.innerHTML = `\n
\n

${headline}

\n ${cta}\n
\n `;\n ```\n\n
\n\n\n### Named variant\n\n```tsx\nconst { headline, cta } = useIntlayer(\"hero-banner\", {\n variant: \"black_friday\",\n});\n```\n\n### Named variant with explicit locale\n\n```tsx\nconst content = useIntlayer(\"hero-banner\", {\n variant: \"black_friday\",\n locale: \"en-GB\",\n});\n```\n\n## Typical use-cases\n\n- A/B copy tests driven by an experiment key\n- Seasonal or promotional banners\n- Feature-flagged messaging\n- Locale-specific marketing campaigns\n","description":"Use the variant metadata field in Intlayer content files to declare named content alternatives — A/B tests, seasonal banners, feature-flagged copy — and switch between them at runtime without code changes.","url":"https://intlayer.org/en-GB/doc/concept/variants","datePublished":"2026-06-12","dateModified":"2026-06-12","version":"9.0.0","keywords":"Variants, A/B Testing, Feature Flags, Dynamic Content, Intlayer, Internationalisation","license":"https://raw.githubusercontent.com/aymericzip/intlayer/refs/heads/main/LICENSE","audience":{"@type":"Audience","audienceType":"Developers, Content Managers"}}
    Author:
    Creation:2026-06-12Last update:2026-06-12

    Variants

    A variant is a set of content files that share the same dictionary key but each carry a different variant name. Intlayer serves the appropriate file based on the selector passed to useIntlayer.

    Declaring variants

    Each file represents one named alternative. Omitting variant (or setting it to "default") marks it as the fallback.

    hero-banner.content.ts
    import { t, type Dictionary } from "intlayer";
    
    const dictionary = {
      key: "hero-banner",
      variant: "default",
      content: {
        headline: t({
          en: "Build faster with Intlayer",
          fr: "Développez plus vite avec Intlayer",
        }),
        cta: t({ en: "Get started", fr: "Commencer" }),
      },
    } satisfies Dictionary;
    
    export default dictionary;
    hero-banner.black-friday.content.ts
    import { t, type Dictionary } from "intlayer";
    
    const dictionary = {
      key: "hero-banner",
      variant: "black_friday",
      content: {
        headline: t({
          en: "50 % off — today only",
          fr: "−50 % — aujourd'hui seulement",
        }),
        cta: t({ en: "Shop now", fr: "Acheter maintenant" }),
      },
    } satisfies Dictionary;
    
    export default dictionary;

    Consuming variants

    Default variant

    Hero.tsx
    import { useIntlayer } from "react-intlayer";
    
    export const Hero = () => {
      const { headline, cta } = useIntlayer("hero-banner");
      // → default variant
    
      return (
        <section>
          <h1>{headline}</h1>
          <a>{cta}</a>
        </section>
      );
    };

    Named variant

    tsx
    const { headline, cta } = useIntlayer("hero-banner", {  variant: "black_friday",});

    Named variant with explicit locale

    tsx
    const content = useIntlayer("hero-banner", {  variant: "black_friday",  locale: "en-GB",});

    Typical use-cases

    • A/B copy tests driven by an experiment key
    • Seasonal or promotional banners
    • Feature-flagged messaging
    • Locale-specific marketing campaigns