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
      • 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
  • Identifying element types
  • Element presets
  • Element type methods
  • Best Practices for Element Type Methods
Elements

Element Types & Methods

Was this page helpful?
Previous

Element Presets

Next
Built with

Each element in Webflow has a specific type that determines its functionality and available methods. While all elements share some common properties, each element type also has specialized methods that allow you to manipulate that element’s unique characteristics.

Identifying element types

You can identify an element’s type using the element.type property:

1const element = await Webflow.getSelectedElement();
2console.log(element.type); // "DOM", "String", "Image", etc.

Element presets

To add a specific element type to the canvas, you can use the webflow.elementPresets object, which contains a set of presets for different element types available in the designer.

1const element = await webflow.elementPresets.DOM;
2await webflow.addElement(element);

Element type methods

Different element types have unique methods tailored to their functionality. Always check an element’s type before applying type-specific methods.

DOM Elements

Customize HTML elements with methods for HTML tags and attributes.

Strings

Work with text content and manipulate their text values.

Images

Manage images and alt text.

Headings

Modify heading levels and heading content.

Links

Configure links with methods for URLs, targets, and link settings.

Forms

Create and configure forms and form field settings.

Components

Get components definitions from a component instance.

Best Practices for Element Type Methods

  1. Always check element type before applying type-specific methods:

    1if (element.type === "Image") {
    2 // Now it's safe to use Image methods
    3 await element.setAltText("Description");
    4}
  2. Handle multiple element types with type guards:

    1function handleElement(element) {
    2 switch(element.type) {
    3 case "String":
    4 return element.getText();
    5 case "Image":
    6 return element.getAsset();
    7 default:
    8 return null;
    9 }
    10}
  3. Combine property and type checks for maximum safety:

    1if (element.type === "DOM" && element.children) {
    2 // Safe to use DOM methods and children methods
    3 await element.setTag("div");
    4 await element.append(Webflow.elementPresets.Paragraph);
    5}