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
        • Search element settings
        • Get settings
        • Get resolved settings
        • Set settings
        • Get visibility
        • Set visibility
        • Get DOM ID
        • Set DOM ID
        • Search bindable sources
      • Attributes
      • Custom Attributes
      • Styles
      • Text Content
      • Display Name
    • Element Types & Methods
  • 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
  • element.setVisibility(visibility)
  • Syntax
  • Parameters
  • Returns
  • Example
  • Designer Ability
ElementsElement Properties & MethodsSettings

Set visibility (Beta)

Was this page helpful?
Previous

Get DOM ID (Beta)

Next
Built with

element.setVisibility(visibility)

Set the visibility of an element, or bind its visibility state to a data source.

Verify that the element has the visibility property before calling this method.

Beta

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

Syntax

1element.setVisibility(visibility: boolean): Promise<null>
2element.setVisibility(binding: BindingInput): Promise<null>

Related types:

1type BindingInput =
2 | { sourceType: 'prop'; propId: string }
3 | { sourceType: 'cms'; collectionId: string; fieldId: string }
4 | { sourceType: 'page'; fieldKey: string }
5 | { sourceType: 'locale'; fieldKey: string }
6 | { sourceType: 'localeItem'; fieldKey: string };

Parameters

  • visibility: boolean | BindingInput — true to show the element or false to hide it. Pass a BindingInput object to bind the visibility to a data source such as a CMS boolean field or component prop.

Returns

Promise<null>

A promise that resolves to null on success.

Example

1const element = await webflow.getSelectedElement();
2
3if (element?.visibility) {
4
5 // Hide the element
6 await element.setVisibility(false);
7
8 // Show the element
9 await element.setVisibility(true);
10
11 // Bind visibility to a CMS boolean field
12 await element.setVisibility({
13 sourceType: 'cms',
14 collectionId: 'col_abc',
15 fieldId: 'field_xyz',
16 });
17}

Designer Ability

Designer AbilityLocaleBranchWorkflowSitemode
canDesignPrimaryMainCanvasDesign