How can I make a div block conditionally visible in Webflow based on whether one of two links is set?

Published on
September 22, 2023

To conditionally show or hide a div block in Webflow based on the selection of one of two links, you can follow these steps:

  1. Create the div block: Start by creating the div block that you want to conditionally show or hide. Give it a unique class name for easy targeting.

  2. Set default visibility: By default, the div block should either be visible or hidden. Determine the initial visibility state of the div block and set it using either the Style panel or by adding appropriate custom code.

  3. Add link elements: Next, add the two link elements to your design. Give each link a unique class name to target them later.

  4. Create an interaction: To create the conditional visibility behavior, you will use interactions. Open the Interactions panel and click on the "+" icon to create a new interaction.

  5. Set up trigger: Choose the trigger type for your interaction. In this case, you will select the "Link Clicked" trigger, and then select the two link elements you created earlier.

  6. Define the actions: Within the interaction, create two actions. The first action should be "Hide" for the div block that you want to conditionally show or hide. Select the div block from the "Elements" dropdown, and choose the "Hide" animation.

  7. Create a condition: After the "Hide" action, add a condition to check which link was clicked. Select the "Equal to" condition, and choose the class name of the link that corresponds to showing the div block. Select the appropriate link from the "Elements" dropdown.

  8. Add show action: Below the condition, add a "Show" action for the div block. Select the div block from the "Elements" dropdown, and choose the "Show" animation.

  9. Repeat for the other link: Duplicate the actions you set up in steps 6-8 to handle the case when the other link is clicked. Update the condition for the second set of actions to target the other link.

  10. Preview and test: Preview your website to test the conditional visibility behavior. Clicking on one of the two links should show the div block while hiding it when the other link is clicked.

By following these steps, you can create conditional visibility for a div block in Webflow based on the selection of one of two links. This allows you to control the visibility of elements on your website dynamically in response to user interactions.

Additional Questions:

  1. How can I show and hide elements dynamically based on user input in Webflow?
  2. Can I use custom code to conditionally show or hide elements in Webflow?
  3. What other types of interactions can I create in Webflow to enhance the user experience?