Condition recipes
These are the TeleportHQ conditions people ask for most, each with the value to create and the rule to set in the Conditional Rendering section of the right panel. Each one works on a website as well as a web app, and none needs the AI. Where TeleportHQ has a ready-made element that does the same, the recipe names it first: Accordion, Tabs and Slider are in Elements → Primitives → Interactive, and build their own show-and-hide.
The steps for creating a state and binding a rule are in How to show or hide elements by state. The operators (=, !=, >, is_empty and the rest) are listed in How to show or hide elements based on a condition.
An accordion
Ready-made: the Accordion element has an Accordion Trigger and an Accordion Content, a Default state (Open or Closed) and a Group Name so one answer at a time stays open. See How to create an accordion.
With a condition, for a layout the element doesn't give you:
- In Page settings → State, create
openQuestion, type number, default0. - Select the first answer. Rule:
openQuestion=1. The second answer:openQuestion=2, and so on. - On each question's heading, add a Change State event: Modifies
openQuestion, To its number. A heading that sets it to0closes everything.
Tabs
Ready-made: the Tabs element shows one panel per tab, with Current tab and Direction in its Tabs settings, and can take its tabs from data (Tabs source).
With a condition:
- Create
activeTab, type number, default1. - Rule on the first panel:
activeTab=1; on the second:activeTab=2. - Each tab button gets a Change State event that sets
activeTabto its number. To mark the active button, give it a class with a rendering condition on the same rule. See How to use conditions in components and variants.
A monthly/yearly price toggle is the same recipe with a text state billing, default monthly, and rules billing = monthly on one price list and = yearly on the other.
An image slider
Ready-made: the Slider element has slides, arrows, dots, autoplay and seven layouts. See How to create an image slider.
With a condition, for a "before and after" or a three-image showcase:
- Create
slide, type number, default1. - Rule on the first image:
slide=1; on the second:slide=2; on the third:slide=3. - Three small buttons set
slideto1,2and3. The Next button needs one rule per position: a Next withslide=1that sets2, another withslide=2that sets3.
A "no results" message
For items held in a state filled from your data (see Fill a state from your data):
- Select the "No results" text.
- Rule: the state, for example
products, with the operatoris_empty. No value is needed. - Give the list the opposite rule,
productsis_not_empty, so the two never show together.
For a CMS List or an Array Mapper bound to a data source, the list has its own empty state. See How to design loading, empty and error states.
A block for one language
On a multilingual site, a block that only German readers should see, for example a note on German delivery:
- Select the block.
- Click Bind → Dynamic Properties Assignment Panel, open global → Current Language, click
short, then Bind property. - Keep
=. The value list offers your site's language codes: pickde.
For a rule on the language's name, pick name instead of short: the list then offers the names. A language switcher that shows a flag per language uses the same idea on each item of the switcher's list. See How to add a language switcher.
A field that is sometimes empty
Two ways, depending on what the reader should see:
- Hide the element when the field is empty: on the element, rule
description!=with an empty value box for a text, ortagsis_not_emptyfor a list. - Show a placeholder instead: type a fallback in the box under the binding, such as "No description yet". See How to show a fallback when data is missing.
Good to know
- See the hidden version while designing with the Set … to … button in the Conditional Rendering section, or with See all conditionally rendered nodes at the bottom center of the canvas.
- The canvas switch. When a state switches one section between views, point at the section: a small switch on the canvas lists the views.
- Downloaded code. The HTML download runs the state recipes above; the language and data recipes need the Next.js download. See How to download your site as code.