Skip to main content
Version: Latest

Display Conditions

Conditionally show or hide content rows based on recipient attributes, enabling targeted content within a single design.

import { useRef } from "react";
import { DragbleEditor, DragbleEditorRef } from "dragble-react-editor";

function ConditionalEditor() {
const editorRef = useRef<DragbleEditorRef>(null);

return (
<DragbleEditor
ref={editorRef}
editorKey="db_your_key"
editorMode="email"
options={{
displayConditions: {
enabled: true,
conditions: [
{
label: "Subscription Plan",
field: "plan",
operators: ["equals", "not_equals"],
values: [
{ label: "Free", value: "free" },
{ label: "Pro", value: "pro" },
{ label: "Enterprise", value: "enterprise" },
],
},
{
label: "Country",
field: "country",
operators: ["equals", "not_equals", "contains"],
values: [
{ label: "United States", value: "US" },
{ label: "United Kingdom", value: "GB" },
{ label: "Germany", value: "DE" },
],
},
],
},
}}
/>
);
}

Users can right-click any row and select Display Condition to apply rules. Rows with conditions show a badge in the editor.

Update conditions at runtime

// React
editorRef.current?.editor?.setDisplayConditions({
enabled: true,
conditions: [
{
label: "VIP Status",
field: "is_vip",
operators: ["equals"],
values: [
{ label: "Yes", value: "true" },
{ label: "No", value: "false" },
],
},
],
});

// Vanilla JS
dragble.setDisplayConditions({
enabled: true,
conditions: [
/* ... */
],
});

:::info Conditions are metadata only The editor stores conditions as metadata in the design JSON. Your sending platform is responsible for evaluating conditions and filtering rows at render time. :::

:::tip Operators Available operators: equals, not_equals, contains, not_contains, starts_with, ends_with, greater_than, less_than. :::

Method reference

MethodReturnsDescription
setDisplayConditions(config)voidReplace display conditions configuration at runtime

Next steps

  • Merge Tags -- personalize content with dynamic tokens
  • Dynamic Images -- personalize images using merge tags in URLs
  • Modules -- create reusable conditional content blocks
  • Validation -- verify condition rules before sending