From 45c1d344cb251eabaa5a98b4d38bb542d3f45de6 Mon Sep 17 00:00:00 2001 From: Ahmed Sohail Date: Sat, 28 Nov 2026 02:02:16 +0500 Subject: [PATCH] Clarify Dash callback triggered_id return values --- dash/_callback_context.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dash/_callback_context.py b/dash/_callback_context.py index d113a0d950..62277f33ca 100644 --- a/dash/_callback_context.py +++ b/dash/_callback_context.py @@ -121,7 +121,9 @@ def triggered_prop_ids(self): @has_context def triggered_id(self): """ - Returns the component id (str or dict) of the Input component that triggered the callback. + Returns the component id of the Input that triggered the callback. The id is a string + for a regular component and a dictionary for a pattern-matching component. + Returns None when no Input triggered the callback, such as on an initial call. Note - use `triggered_prop_ids` if you need both the component id and the prop that triggered the callback or if multiple Inputs triggered the callback. @@ -130,6 +132,11 @@ def triggered_id(self): `if "btn-1" == ctx.triggered_id: do_something()` + Example - read a key from a pattern-matching id: + `triggered_id = ctx.triggered_id + if isinstance(triggered_id, dict): + index = triggered_id.get("index")` + """ component_id = None if self.triggered: