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
  • Styles
    • Managing Style Properties
    • Managing Variable Modes
  • Components
  • Variables & Collections
    • Variable Collections
    • Variables
    • Variable Modes
  • Assets
  • Pages & Folders
  • Utilities
      • Get site information
      • Resize the extension
      • Close the extension
      • Get the current breakpoint
      • Get user ID token
      • Get user's Designer capabilities
      • Get the current Designer mode
      • Check for a Designer mode
      • Get the Designer's pseudo-state
      • Get launch context
      • Get app subscriptions
      • Get theme
      • Get theme styles
    • User Events & Notifications
    • App Intents & Connections
  • Additional Resources
    • API Playground
    • FAQs
LogoLogo
Resources
Get started
On this page
  • webflow.isMode()
  • Syntax
  • Parameters
  • Returns
  • Example
  • Example: Checking a mode before an action
UtilitiesSite Information & Settings

Check for a Designer mode

Was this page helpful?
Previous

Get the pseudo state

Next
Built with

webflow.isMode()

Returns a boolean that shows whether the Designer is currently in the specified mode.

Use this method when you need to branch on a single mode and don’t need the full list of modes. To read the current mode directly, use webflow.getCurrentMode().

Syntax

1webflow.isMode(mode: AppModeName): Promise<boolean>

Parameters

mode: AppModeName

The mode to check for. One of "design", "build", "preview", "edit", or "comment". See webflow.getCurrentMode() for the full list of modes and what each one represents.

Returns

Promise<boolean>

A Promise that resolves to true when the Designer is in the specified mode, or false otherwise.

Example

1if (await webflow.isMode("design")) {
2 // Run layout-editing code only in Design mode.
3 await insertElement();
4}

Try this example

Example: Checking a mode before an action

Block an action and notify the user when the Designer is in the wrong mode for the operation:

1async function insertDivIfInDesignMode() {
2 if (!(await webflow.isMode("design"))) {
3 await webflow.notify({
4 type: "Error",
5 message: "Switch to Design mode to insert elements.",
6 });
7 return;
8 }
9
10 const el = await webflow.getSelectedElement();
11 if (el) {
12 await el.append(webflow.elementPresets.DivBlock);
13 }
14}
15
16await insertDivIfInDesignMode();

Try this example