With the release of Content SDK 1.2, variants can now be created in separate files located alongside the main component file. This major enhancement geared towards component structuring provides developers with greater flexibility and clarity when managing multiple component versions.
Key Benefits
Improved organization - variants are stored next to their parent component, making file structures more intuitive and maintainable.
Scalable approach - ideal for projects with numerous variants, ensuring consistency and discoverability.
Enhanced developer experience - originally designed to support Design Studio, this feature now benefits all component-based workflows.
What’s New
Variants use a dot-separated suffix (e.g.,
Promo.ImageLeft.tsx) and are grouped under a single entry in the component map.CLI configuration option to enable or disable variant file discovery.
Code extraction updated to include variant files and provide variant name labels.
Example Component Structure
src/
└── components/
└── promo/
├── Promo.tsx
├── Promo.ImageLeft.tsx
└── Promo.ImageRight.tsxComponent Map Example
['Promo',{...Promo, ...PromoImageLeft, ...PromoImageRight}]