what are you trying to do?
Set a non-100% default maxWidth on a code component via registerComponent({ ..., defaultStyles: { maxWidth: '...' } }), so newly-instantiated instances don’t come in stretched to full container width.
Every value I’ve tried (0, null, undefined, '', 'none', '500px') is silently ignored. The Size panel always shows Max Width = 100% on instantiation. Same behavior on defaultStyles.objectFit for code components — always forced to cover.
Per the doc contract on defaultStyles in @plasmicapp/host:
Default styles to start with when instantiating the component in Plasmic.
So I’d expect the value I pass in to actually be the starting value.
what are the reproduction steps?
-
Register any code component:
registerComponent(MyComponent, { name: 'MyComponent', importPath: './MyComponent', defaultStyles: { maxWidth: 'none' }, // or any other value props: { /* ... */ }, }); -
Open Plasmic Studio, drop the component onto the canvas.
-
Open the Size section — Max Width shows
100%, not the value passed.
root cause (from source)
platform/wab/src/wab/shared/VariantTplMgr.ts ~L734:
const exp = RSH(this.ensureBaseVariantSetting(tpl).rs, tpl);
exp.set("max-width", "100%"); // clobbers defaultStyles
if (isCodeComponent(props.component)) {
exp.set("object-fit", "cover"); // same
}