For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceGuidesExamplesChangelog
ReferenceGuidesExamplesChangelog
  • Designer API
    • Introduction
    • Getting Started
    • Webflow CLI
    • Error Handling
    • App Modes
  • Elements
    • Creating & Retrieving Elements
    • Element Properties & Methods
    • Element Types & Methods
      • Element Presets
      • DOM Elements
      • Strings
      • Components
      • Slots
        • Get display name
        • Get Children
        • Prepend
        • Append
      • Headings
      • Images
      • Links
      • Forms
  • Styles
    • Managing Style Properties
    • Managing Variable Modes
  • Components
  • Variables & Collections
    • Variable Collections
    • Variables
    • Variable Modes
  • Assets
  • Pages & Folders
  • Utilities
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • slot.prepend(component)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer Ability
ElementsElement Types & MethodsSlots

Prepend (Beta)

Was this page helpful?
Previous

Append (Beta)

Next
Built with

slot.prepend(component)

Add a component instance as the first child of the slot.

Only component instances can be added to slots. Components from installed libraries are not supported; only components in the site’s own component library can be added to a slot. This action is undoable via the Designer’s undo stack.

Beta

These methods are in public beta and may change with future releases.

Syntax

1slot.prepend(component: Component): Promise<null>

Parameters

  • component: Component — The component definition to instantiate and insert at the beginning of the slot.

Returns

Promise<null>

A Promise that resolves when the component instance is added.

Example

1// Get a component instance on the page
2const elements = await webflow.getAllElements();
3const componentInstance = elements.find(el => el.type === 'ComponentInstance');
4
5if (componentInstance?.type === 'ComponentInstance') {
6
7 // Get the first slot on the instance
8 const slots = await componentInstance.getSlots();
9 const firstSlot = slots[0];
10
11 if (firstSlot) {
12
13 // Find the component to add
14 const components = await webflow.getAllComponents();
15 const cardComponent = await webflow.getComponentByName('Card');
16
17 if (cardComponent) {
18
19 // Prepend a component instance to the slot
20 await firstSlot.prepend(cardComponent);
21
22 }
23 }
24
25} else {
26 console.log('No component instance found');
27}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canDesignAnyAnyCanvasAny