Repository: Textualize/textual

Issue:
Ability to rename tabs (TabPane).
Currently this is not supported AFAIK. If one wants to change the title of a tab, they need to remove and add it again.
Fetching the `Tab` within `TabPane` and updating it doesn't fully work, for instance the underline does not adapt.


Discussion:
To add to the above, this can pretty much be done right now with code like this:

```python
from textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Label

class TCRenameApp(App[None]):

    BINDINGS = [
        ("space", "rename"),
    ]

    def compose(self) -> ComposeResult:
        with TabbedContent():
            with TabPane("One", id="one"):
                yield Label("Press space to change my Tab's label")
            with TabPane("Two", id="two"):
                yield Label("This one won't rename")

    def action_rename(self) -> None:
        self.query_one(TabbedContent).get_tab("one").update("Renamed!")

if __name__ == "__main__":
    TCRenameApp().run()
```

but the `Tab.update` doesn't refresh the underline, so you go from this:

![Screenshot 2023-12-19 at 07 48 17](https://github.com/Textualize/textual/assets/28237/5245fcd6-32ce-4946-8580-d8a5918c2d2c)

to this:

![Screenshot 2023-12-19 at 07 48 23](https://github.com/Textualize/textual/assets/28237/16ea5f1b-5208-4cd9-9f96-cc99c3fee12c)

At its most basic level this could be an issue to ensure that the underline gets a refresh; but it could also be an issue for adding a `TabbedContent` API call for relabelling a tab.

---
@ggozad Thinking about it some more this morning, you *can* do what you want like this:

```python
from textual.app import App, ComposeResult
from textual.widgets import TabbedContent, TabPane, Label, Tabs

class TCRenameApp(App[None]):

    BINDINGS = [
        ("space", "rename"),
    ]

    def compose(self) -> ComposeResult:
        with TabbedContent():
            with TabPane("One", id="one"):
                yield Label("Press space to change my Tab's label")
            with TabPane("Two", id="two"):
                yield Label("This one won't rename")

    def action_rename(self) -> None:
        tabbed_content = self.query_one(TabbedContent)
        tabbed_content.get_tab("one").update("Renamed!")
        tabbed_content.query_one(Tabs).show("one")

if __name__ == "__main__":
    TCRenameApp().run()
```

that call to `show` the tab again will cause it to refresh (although I do feel a more coherent API call for this would make sense).
Oooh thank you @davep !
This covers me, at least I no longer need to recreate the tab.
I will leave this open in case you decide you want to wrap it up in a documented API, but if you feel this is too much of an edge case please close the issue.
@ggozad My pleasure. I'm inclined to leave this open as I feel this is an obvious thing to want to do and it should probably have a very obvious API. Thanks for raising it.
Let's add a more elegant API for this.

Resolving patch:
diff --git a/src/textual/widgets/_tabs.py b/src/textual/widgets/_tabs.py
--- a/src/textual/widgets/_tabs.py
+++ b/src/textual/widgets/_tabs.py
@@ -5,6 +5,7 @@
 from typing import ClassVar
 
 import rich.repr
+from rich.console import RenderableType
 from rich.style import Style
 from rich.text import Text, TextType
 
@@ -143,6 +144,9 @@ class Disabled(TabMessage):
     class Enabled(TabMessage):
         """A tab was enabled."""
 
+    class Relabelled(TabMessage):
+        """A tab was relabelled."""
+
     def __init__(
         self,
         label: TextType,
@@ -159,9 +163,23 @@ def __init__(
             classes: Space separated list of class names.
             disabled: Whether the tab is disabled or not.
         """
-        self.label = Text.from_markup(label) if isinstance(label, str) else label
         super().__init__(id=id, classes=classes, disabled=disabled)
-        self.update(label)
+        self._label: Text
+        self.label = label
+
+    @property
+    def label(self) -> Text:
+        """The label for the tab."""
+        return self._label
+
+    @label.setter
+    def label(self, label: TextType) -> None:
+        self._label = Text.from_markup(label) if isinstance(label, str) else label
+        self.update(self._label)
+
+    def update(self, renderable: RenderableType = "") -> None:
+        self.post_message(self.Relabelled(self))
+        return super().update(renderable)
 
     @property
     def label_text(self) -> str:
@@ -693,6 +711,11 @@ def _on_tab_enabled(self, event: Tab.Enabled) -> None:
         event.stop()
         self.post_message(self.TabEnabled(self, event.tab))
 
+    def _on_tab_relabelled(self, event: Tab.Relabelled) -> None:
+        """Redraw the highlight when tab is relabelled."""
+        event.stop()
+        self._highlight_active()
+
     def disable(self, tab_id: str) -> Tab:
         """Disable the indicated tab.
 


Test patch:
diff --git a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
--- a/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
+++ b/tests/snapshot_tests/__snapshots__/test_snapshots.ambr
@@ -32386,6 +32386,165 @@
   
   '''
 # ---
+# name: test_tab_rename
+  '''
+  <svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
+      <!-- Generated with Rich https://www.textualize.io -->
+      <style>
+  
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Regular"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
+          font-style: normal;
+          font-weight: 400;
+      }
+      @font-face {
+          font-family: "Fira Code";
+          src: local("FiraCode-Bold"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
+                  url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
+          font-style: bold;
+          font-weight: 700;
+      }
+  
+      .terminal-1525284282-matrix {
+          font-family: Fira Code, monospace;
+          font-size: 20px;
+          line-height: 24.4px;
+          font-variant-east-asian: full-width;
+      }
+  
+      .terminal-1525284282-title {
+          font-size: 18px;
+          font-weight: bold;
+          font-family: arial;
+      }
+  
+      .terminal-1525284282-r1 { fill: #c5c8c6 }
+  .terminal-1525284282-r2 { fill: #e1e1e1 }
+  .terminal-1525284282-r3 { fill: #e1e1e1;font-weight: bold }
+  .terminal-1525284282-r4 { fill: #737373 }
+  .terminal-1525284282-r5 { fill: #474747 }
+  .terminal-1525284282-r6 { fill: #0178d4 }
+      </style>
+  
+      <defs>
+      <clipPath id="terminal-1525284282-clip-terminal">
+        <rect x="0" y="0" width="975.0" height="584.5999999999999" />
+      </clipPath>
+      <clipPath id="terminal-1525284282-line-0">
+      <rect x="0" y="1.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-1">
+      <rect x="0" y="25.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-2">
+      <rect x="0" y="50.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-3">
+      <rect x="0" y="74.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-4">
+      <rect x="0" y="99.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-5">
+      <rect x="0" y="123.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-6">
+      <rect x="0" y="147.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-7">
+      <rect x="0" y="172.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-8">
+      <rect x="0" y="196.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-9">
+      <rect x="0" y="221.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-10">
+      <rect x="0" y="245.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-11">
+      <rect x="0" y="269.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-12">
+      <rect x="0" y="294.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-13">
+      <rect x="0" y="318.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-14">
+      <rect x="0" y="343.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-15">
+      <rect x="0" y="367.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-16">
+      <rect x="0" y="391.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-17">
+      <rect x="0" y="416.3" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-18">
+      <rect x="0" y="440.7" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-19">
+      <rect x="0" y="465.1" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-20">
+      <rect x="0" y="489.5" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-21">
+      <rect x="0" y="513.9" width="976" height="24.65"/>
+              </clipPath>
+  <clipPath id="terminal-1525284282-line-22">
+      <rect x="0" y="538.3" width="976" height="24.65"/>
+              </clipPath>
+      </defs>
+  
+      <rect fill="#292929" stroke="rgba(255,255,255,0.35)" stroke-width="1" x="1" y="1" width="992" height="633.6" rx="8"/><text class="terminal-1525284282-title" fill="#c5c8c6" text-anchor="middle" x="496" y="27">TabRenameApp</text>
+              <g transform="translate(26,22)">
+              <circle cx="0" cy="0" r="7" fill="#ff5f57"/>
+              <circle cx="22" cy="0" r="7" fill="#febc2e"/>
+              <circle cx="44" cy="0" r="7" fill="#28c840"/>
+              </g>
+          
+      <g transform="translate(9, 41)" clip-path="url(#terminal-1525284282-clip-terminal)">
+      <rect fill="#1e1e1e" x="0" y="1.5" width="512.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="512.4" y="1.5" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="561.2" y="1.5" width="61" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="622.2" y="1.5" width="73.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="695.4" y="1.5" width="85.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="780.8" y="1.5" width="97.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="878.4" y="1.5" width="97.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="25.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="24.4" y="25.9" width="475.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="500.2" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="512.4" y="25.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="536.8" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="549" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="561.2" y="25.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="585.6" y="25.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="610" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="622.2" y="25.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="646.6" y="25.9" width="36.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="683.2" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="695.4" y="25.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="719.8" y="25.9" width="48.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="768.6" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="780.8" y="25.9" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="805.2" y="25.9" width="61" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="866.2" y="25.9" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="878.4" y="25.9" width="97.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="12.2" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="24.4" y="50.3" width="475.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="500.2" y="50.3" width="12.2" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="512.4" y="50.3" width="463.6" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="74.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="99.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="24.4" y="99.1" width="85.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="109.8" y="99.1" width="61" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="170.8" y="99.1" width="780.8" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="951.6" y="99.1" width="24.4" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="123.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="147.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="172.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="196.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="221.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="245.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="269.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="294.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="318.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="343.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="367.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="391.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="416.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="440.7" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="465.1" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="489.5" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="513.9" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="538.3" width="976" height="24.65" shape-rendering="crispEdges"/><rect fill="#1e1e1e" x="0" y="562.7" width="976" height="24.65" shape-rendering="crispEdges"/>
+      <g class="terminal-1525284282-matrix">
+      <text class="terminal-1525284282-r1" x="976" y="20" textLength="12.2" clip-path="url(#terminal-1525284282-line-0)">
+  </text><text class="terminal-1525284282-r3" x="24.4" y="44.4" textLength="475.8" clip-path="url(#terminal-1525284282-line-1)">This&#160;is&#160;a&#160;much&#160;longer&#160;label&#160;for&#160;the&#160;tab</text><text class="terminal-1525284282-r4" x="536.8" y="44.4" textLength="12.2" clip-path="url(#terminal-1525284282-line-1)">0</text><text class="terminal-1525284282-r4" x="585.6" y="44.4" textLength="24.4" clip-path="url(#terminal-1525284282-line-1)">11</text><text class="terminal-1525284282-r4" x="646.6" y="44.4" textLength="36.6" clip-path="url(#terminal-1525284282-line-1)">222</text><text class="terminal-1525284282-r4" x="719.8" y="44.4" textLength="48.8" clip-path="url(#terminal-1525284282-line-1)">3333</text><text class="terminal-1525284282-r4" x="805.2" y="44.4" textLength="61" clip-path="url(#terminal-1525284282-line-1)">44444</text><text class="terminal-1525284282-r1" x="976" y="44.4" textLength="12.2" clip-path="url(#terminal-1525284282-line-1)">
+  </text><text class="terminal-1525284282-r5" x="0" y="68.8" textLength="12.2" clip-path="url(#terminal-1525284282-line-2)">━</text><text class="terminal-1525284282-r5" x="12.2" y="68.8" textLength="12.2" clip-path="url(#terminal-1525284282-line-2)">╸</text><text class="terminal-1525284282-r6" x="24.4" y="68.8" textLength="475.8" clip-path="url(#terminal-1525284282-line-2)">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</text><text class="terminal-1525284282-r5" x="500.2" y="68.8" textLength="12.2" clip-path="url(#terminal-1525284282-line-2)">╺</text><text class="terminal-1525284282-r5" x="512.4" y="68.8" textLength="463.6" clip-path="url(#terminal-1525284282-line-2)">━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━</text><text class="terminal-1525284282-r1" x="976" y="68.8" textLength="12.2" clip-path="url(#terminal-1525284282-line-2)">
+  </text><text class="terminal-1525284282-r1" x="976" y="93.2" textLength="12.2" clip-path="url(#terminal-1525284282-line-3)">
+  </text><text class="terminal-1525284282-r2" x="24.4" y="117.6" textLength="85.4" clip-path="url(#terminal-1525284282-line-4)">TabPane</text><text class="terminal-1525284282-r3" x="109.8" y="117.6" textLength="61" clip-path="url(#terminal-1525284282-line-4)">#test</text><text class="terminal-1525284282-r1" x="976" y="117.6" textLength="12.2" clip-path="url(#terminal-1525284282-line-4)">
+  </text><text class="terminal-1525284282-r1" x="976" y="142" textLength="12.2" clip-path="url(#terminal-1525284282-line-5)">
+  </text><text class="terminal-1525284282-r1" x="976" y="166.4" textLength="12.2" clip-path="url(#terminal-1525284282-line-6)">
+  </text><text class="terminal-1525284282-r1" x="976" y="190.8" textLength="12.2" clip-path="url(#terminal-1525284282-line-7)">
+  </text><text class="terminal-1525284282-r1" x="976" y="215.2" textLength="12.2" clip-path="url(#terminal-1525284282-line-8)">
+  </text><text class="terminal-1525284282-r1" x="976" y="239.6" textLength="12.2" clip-path="url(#terminal-1525284282-line-9)">
+  </text><text class="terminal-1525284282-r1" x="976" y="264" textLength="12.2" clip-path="url(#terminal-1525284282-line-10)">
+  </text><text class="terminal-1525284282-r1" x="976" y="288.4" textLength="12.2" clip-path="url(#terminal-1525284282-line-11)">
+  </text><text class="terminal-1525284282-r1" x="976" y="312.8" textLength="12.2" clip-path="url(#terminal-1525284282-line-12)">
+  </text><text class="terminal-1525284282-r1" x="976" y="337.2" textLength="12.2" clip-path="url(#terminal-1525284282-line-13)">
+  </text><text class="terminal-1525284282-r1" x="976" y="361.6" textLength="12.2" clip-path="url(#terminal-1525284282-line-14)">
+  </text><text class="terminal-1525284282-r1" x="976" y="386" textLength="12.2" clip-path="url(#terminal-1525284282-line-15)">
+  </text><text class="terminal-1525284282-r1" x="976" y="410.4" textLength="12.2" clip-path="url(#terminal-1525284282-line-16)">
+  </text><text class="terminal-1525284282-r1" x="976" y="434.8" textLength="12.2" clip-path="url(#terminal-1525284282-line-17)">
+  </text><text class="terminal-1525284282-r1" x="976" y="459.2" textLength="12.2" clip-path="url(#terminal-1525284282-line-18)">
+  </text><text class="terminal-1525284282-r1" x="976" y="483.6" textLength="12.2" clip-path="url(#terminal-1525284282-line-19)">
+  </text><text class="terminal-1525284282-r1" x="976" y="508" textLength="12.2" clip-path="url(#terminal-1525284282-line-20)">
+  </text><text class="terminal-1525284282-r1" x="976" y="532.4" textLength="12.2" clip-path="url(#terminal-1525284282-line-21)">
+  </text><text class="terminal-1525284282-r1" x="976" y="556.8" textLength="12.2" clip-path="url(#terminal-1525284282-line-22)">
+  </text>
+      </g>
+      </g>
+  </svg>
+  
+  '''
+# ---
 # name: test_tabbed_content
   '''
   <svg class="rich-terminal" viewBox="0 0 994 635.5999999999999" xmlns="http://www.w3.org/2000/svg">
diff --git a/tests/snapshot_tests/snapshot_apps/tab_rename.py b/tests/snapshot_tests/snapshot_apps/tab_rename.py
new file mode 100644
--- /dev/null
+++ b/tests/snapshot_tests/snapshot_apps/tab_rename.py
@@ -0,0 +1,16 @@
+from textual.app import App, ComposeResult
+from textual.widgets import TabbedContent, TabPane
+
+class TabRenameApp(App[None]):
+
+    def compose(self) -> ComposeResult:
+        with TabbedContent():
+            yield TabPane("!", id="test")
+            for n in range(5):
+                yield TabPane(str(n) * (n+1))
+
+    def on_mount(self) -> None:
+        self.query_one(TabbedContent).get_tab("test").label = "This is a much longer label for the tab"
+
+if __name__ == "__main__":
+    TabRenameApp().run()
diff --git a/tests/snapshot_tests/test_snapshots.py b/tests/snapshot_tests/test_snapshots.py
--- a/tests/snapshot_tests/test_snapshots.py
+++ b/tests/snapshot_tests/test_snapshots.py
@@ -979,3 +979,8 @@ def test_nested_specificity(snap_compare):
     """Test specificity of nested rules is working."""
     # https://github.com/Textualize/textual/issues/3961
     assert snap_compare(SNAPSHOT_APPS_DIR / "nested_specificity.py")
+
+
+def test_tab_rename(snap_compare):
+    """Test setting a new label for a tab amongst a TabbedContent."""
+    assert snap_compare(SNAPSHOT_APPS_DIR / "tab_rename.py")
diff --git a/tests/test_tabs.py b/tests/test_tabs.py
--- a/tests/test_tabs.py
+++ b/tests/test_tabs.py
@@ -13,6 +13,14 @@ async def test_tab_label():
     assert Tab("Pilot").label_text == "Pilot"
 
 
+async def test_tab_relabel():
+    """It should be possible to relabel a tab."""
+    tab = Tab("Pilot")
+    assert tab.label_text == "Pilot"
+    tab.label = "Aeryn"
+    assert tab.label_text == "Aeryn"
+
+
 async def test_compose_empty_tabs():
     """It should be possible to create an empty Tabs."""