Repository: gradio-app/gradio

Issue:
Add copy to clipboard button to other input types
- [x] I have searched to see if a similar issue already exists.

**Is your feature request related to a problem? Please describe.**  
The only input type that shows the copy to clipboard button is JSON. 

**Describe the solution you'd like**  
It would be great if users can optionally show this button for other input types such as gr.TextBox as well.

<img src="https://user-images.githubusercontent.com/6425112/199174802-25e484c6-ddeb-446d-b1de-07f6842758c8.png" width="300" />



Discussion:
Thanks for the suggestion @armancohan. I do think though is that this button is not too crucial for the other components since it is easy enough to select the contents of a Textbox, or right click to copy an image and the presence of such a button would clutter the UI
Hi,

I also would like to have this feature, as the content of the Textbook may be very long.
👍 ok perhaps it's worth adding the `Textbox` component, as well as the upcoming `Code` component, WDYT @pngwn?
I'm looking for this feature as well, really useful for text outputs.
We could add it as an option to the components it makes sense for but might not be a great default?
Sounds good. Fwiw since I originally commented on this issue, I have changed my mind -- I do think it would be quite useful for demos where someone is generating lots of text (e.g. speech-to-text demos)
Might be useful as part of a UI toolkit used for building custom components too. This is a pretty simple issues, we just need to figure out what components to add the feature to + the api.
Seconding.

also looking forward on copy to clipboard on a textbox

Resolving patch:
diff --git a/demo/blocks_essay/run.py b/demo/blocks_essay/run.py
--- a/demo/blocks_essay/run.py
+++ b/demo/blocks_essay/run.py
@@ -14,7 +14,7 @@ def change_textbox(choice):
     radio = gr.Radio(
         ["short", "long", "none"], label="What kind of essay would you like to write?"
     )
-    text = gr.Textbox(lines=2, interactive=True)
+    text = gr.Textbox(lines=2, interactive=True).style(show_copy_button=True)
 
     radio.change(fn=change_textbox, inputs=radio, outputs=text)
 
diff --git a/gradio/components.py b/gradio/components.py
--- a/gradio/components.py
+++ b/gradio/components.py
@@ -444,6 +444,24 @@ def get_interpretation_scores(
             result.append((self.interpretation_separator, 0))
         return result
 
+    def style(
+        self,
+        *,
+        show_copy_button: bool | None = None,
+        container: bool | None = None,
+        **kwargs,
+    ):
+        """
+        This method can be used to change the appearance of the Textbox component.
+        Parameters:
+            show_copy_button: If True, includes a copy button to copy the text in the textbox. Only applies if show_label is True.
+            container: If True, will place the component in a container - providing some extra padding around the border.
+        """
+        if show_copy_button is not None:
+            self._style["show_copy_button"] = show_copy_button
+
+        return Component.style(self, container=container, **kwargs)
+
 
 @document("style")
 class Number(
@@ -3037,9 +3055,6 @@ def __init__(
         self.stateful = True
         IOComponent.__init__(self, value=deepcopy(value), **kwargs)
 
-    def style(self):
-        return self
-
 
 class Variable(State):
     """Variable was renamed to State. This class is kept for backwards compatibility."""


Test patch: