class_docstr: Button that clears the value of a component or a list of components when clicked. It is instantiated with the list of components to clear.
  Preprocessing: passes the button value as a {str} into the function
  Postprocessing: expects a {str} to be returned from a function, which is set as the label of the button
class_docstr_tok: ["Button","that","clears","the","value","of","a","component","or","a","list","of","components","when","clicked",".","It","is","instantiated","with","the","list","of","components","to","clear",".","Preprocessing",":","passes","the","button","value","as","a","{","str","}","into","the","function","Postprocessing",":","expects","a","{","str","}","to","be","returned","from","a","function",",","which","is","set","as","the","label","of","the","button"]
docstr: Adds a component or list of components to the list of components that will be cleared when the button is clicked.
docstr_tok: ["Adds","a","component","or","list","of","components","to","the","list","of","components","that","will","be","cleared","when","the","button","is","clicked","."]
code: def add(
      self, components: None | Component | list[Component]
  ) -> ClearButton:
      """
      Adds a component or list of components to the list of components that will be cleared when the button is clicked.
      """
      from gradio.components import State  # Avoid circular import
  
      if not components:
          # This needs to be here because when the ClearButton is created in an gr.Interface, we don't
          # want to create dependencies for it before we have created the dependencies for the submit function.
          # We generally assume that the submit function dependency is the first thing created in an gr.Interface.
          return self
  
      if isinstance(components, Component):
          components = [components]
      none_values = []
      state_components = []
      initial_states = []
      for component in components:
          if isinstance(component, State):
              state_components.append(component)
              initial_states.append(copy.deepcopy(component.value))
          none = component.postprocess(None)
          if isinstance(none, (GradioModel, GradioRootModel)):
              none = none.model_dump()
          none_values.append(none)
      clear_values = json.dumps(none_values)
      self.click(
          None,
          [],
          components,
          js=f"() => {clear_values}",
          api_name=self.api_name,
          show_api=self.show_api,
      )
      if state_components:
          self.click(
              lambda: resolve_singleton(initial_states),
              None,
              state_components,
              api_name=self.api_name,
              show_api=self.show_api,
          )
      return self
  
file_path: gradio/gradio/components/clear_button.py
imports: from __future__ import annotations
  import copy
  import json
  from typing import Any, Literal
  from gradio_client.documentation import document, set_documentation_group
  from gradio.components import Button, Component
  from gradio.context import Context
  from gradio.data_classes import GradioModel, GradioRootModel
  from gradio.utils import resolve_singleton
label_desc: Use image node_id 2 for calling the ClearButton obj's underlying member method code with example usage: obj.add(components) and returns: self, self