Create a prop (Beta)
Create a prop (Beta)
component.createProp(options)
Creates a new prop on a component. This mirrors the “Create new prop” action in the component props panel in the Webflow Designer.
If a prop with the same name already exists in the same group, the name is automatically incremented.
For example, Heading becomes Heading 2.
To create multiple props at one time, use component.createProps().
Beta
These methods are in public beta and may change with future releases.
Syntax
The CreatePropOptions type is a discriminated union on the type field:
Parameters
-
options: CreatePropOptions — An object specifying the new prop. The shape varies bytype:Common fields (all types):
type: string — The prop type. Supported values:'textContent','string','richText','imageAsset','link','video','number','boolean','id','altText'.name: string — The display name for the prop.group: string — (optional) The group name. Props with the same group appear together in the props panel. Props without a group appear before grouped props.tooltip: string — (optional) Tooltip text shown on hover in the props panel.defaultValue: varies by type — (optional) The default value for the prop. The shape depends on the prop type (see type-specific fields below).
Type-specific fields:
multiline: boolean — ('textContent'only, optional) Whether the text input supports multiple lines.min: number — ('number'only, optional) Minimum allowed value.max: number — ('number'only, optional) Maximum allowed value.decimals: number — ('number'only, optional) Number of decimal places allowed.trueLabel: string — ('boolean'only, optional) Label shown when the value istrue.falseLabel: string — ('boolean'only, optional) Label shown when the value isfalse.
linkpropdefaultValuefields:The
defaultValuefor a'link'prop is a discriminated union on themodefield. The shape oftodepends on themode:Additional fields available on all
modevalues:openInNewTab: boolean — (optional) Whether the link opens in a new tab.rel: string — (optional) Resource hint. Supported values:'preload','prefetch','prerender'.
The
'email'mode also supports:emailSubject: string — (optional) The subject line for the email link.
Returns
Promise<Prop>
A Promise that resolves to the newly created Prop object with computed binding metadata.
The following table shows how each prop type maps to valueType and bindableTo:
Examples
Create a text content prop:
Create a number prop with constraints:
Create a boolean prop with labels:
Create a link prop:
Create an id prop (the default value is normalized automatically):
Create an altText prop using a special value:
Name conflicts auto-increment within the same group: