diff --git a/storybook/src/styles/compiler.ts b/storybook/src/styles/compiler.ts index 8e5b786dc..b039e608a 100644 --- a/storybook/src/styles/compiler.ts +++ b/storybook/src/styles/compiler.ts @@ -165,22 +165,35 @@ export class StylesCompiler { }; const baseClass = typeMap[predicate.targetType] || `.${predicate.targetType.toLowerCase()}`; + const packagePrefix = this.schema.package || ''; - // Add classes - const classSelectors = predicate.classes.map(c => `.${c}`).join(''); + // Add classes with package prefix + const classSelectors = predicate.classes.map(c => { + // If class already has package prefix, use as-is + if (c.startsWith(packagePrefix + '_')) { + return `.${c}`; + } + // Otherwise, add package prefix + return `.${packagePrefix}_${c}`; + }).join(''); // Add states const stateSelectors = predicate.states.map(s => `:${s}`).join(''); - // Generate selector that works with or without base FakeMUI class - // E.g., `.l3-button` will style both `