:github_url: https://github.com/kivymd/KivyMD/blob/master/kivymd/uix/tab/tab.py

Tabs
====

.. py:module:: kivymd.uix.tab.tab

.. autoapi-nested-parse::

   Components/Tabs
   ===============

   .. seealso::

       `Material Design spec, Tabs <https://m3.material.io/components/tabs/overview>`_

   .. rubric:: Tabs organize content across different screens, data sets,
       and other interactions.

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-preview.png
       :align: center

   - Use tabs to group content into helpful categories
   - Two types: primary and secondary
   - Tabs can horizontally scroll, so a UI can have as many tabs as needed
   - Place tabs next to each other as peers

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-types.png
       :align: center

   1. Primary tabs
   2. Secondary tabs

   Usage primary tabs
   ------------------

   Primary tabs should be used when just one set of tabs are needed.

   .. tabs::

       .. tab:: Declarative KV style

           .. code-block:: python

               from kivy.lang import Builder

               from kivymd.app import MDApp
               from kivymd.uix.tab import (
                   MDTabsItem,
                   MDTabsItemIcon,
                   MDTabsItemText,
                   MDTabsBadge,
               )

               KV = '''
               MDScreen:
                   md_bg_color: self.theme_cls.backgroundColor

                   MDTabsPrimary:
                       id: tabs
                       pos_hint: {"center_x": .5, "center_y": .5}

                       MDDivider:
               '''


               class Example(MDApp):
                   def on_start(self):
                       for tab_icon, tab_name in {
                           "airplane": "Flights",
                           "treasure-chest": "Trips",
                           "compass-outline": "Explore",
                       }.items():
                           if tab_icon == "treasure-chest":
                               self.root.ids.tabs.add_widget(
                                   MDTabsItem(
                                       MDTabsItemIcon(
                                           MDTabsBadge(
                                               text="99",
                                           ),
                                           icon=tab_icon,
                                       ),
                                       MDTabsItemText(
                                           text=tab_name,
                                       ),
                                   )
                               )
                           else:
                               self.root.ids.tabs.add_widget(
                                   MDTabsItem(
                                       MDTabsItemIcon(
                                           icon=tab_icon,
                                       ),
                                       MDTabsItemText(
                                           text=tab_name,
                                       ),
                                   )
                               )
                           self.root.ids.tabs.switch_tab(icon="airplane")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return Builder.load_string(KV)


               Example().run()

       .. tab:: Declarative Python style

           .. code-block:: python

               from kivymd.app import MDApp
               from kivymd.uix.divider import MDDivider
               from kivymd.uix.screen import MDScreen
               from kivymd.uix.tab import (
                   MDTabsItem,
                   MDTabsItemIcon,
                   MDTabsItemText,
                   MDTabsBadge,
                   MDTabsPrimary,
               )


               class Example(MDApp):
                   def on_start(self):
                       for tab_icon, tab_name in {
                           "airplane": "Flights",
                           "treasure-chest": "Trips",
                           "compass-outline": "Explore",
                       }.items():
                           if tab_icon == "treasure-chest":
                               self.root.get_ids().tabs.add_widget(
                                   MDTabsItem(
                                       MDTabsItemIcon(
                                           MDTabsBadge(
                                               text="99",
                                           ),
                                           icon=tab_icon,
                                       ),
                                       MDTabsItemText(
                                           text=tab_name,
                                       ),
                                   )
                               )
                           else:
                               self.root.get_ids().tabs.add_widget(
                                   MDTabsItem(
                                       MDTabsItemIcon(
                                           icon=tab_icon,
                                       ),
                                       MDTabsItemText(
                                           text=tab_name,
                                       ),
                                   )
                               )
                           self.root.get_ids().tabs.switch_tab(icon="airplane")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return (
                           MDScreen(
                               MDTabsPrimary(
                                   MDDivider(),
                                   id="tabs",
                                   pos_hint={"center_x": .5, "center_y": .5},
                               ),
                               md_bg_color=self.theme_cls.backgroundColor,
                           )
                       )


               Example().run()

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-primary-usage.png
       :align: center

   Anatomy primary tabs
   --------------------

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-primary-anatomy.png
       :align: center

   Usage secondary tabs
   --------------------

   Secondary tabs are necessary when a screen requires more than one level of
   tabs. These tabs use a simpler style of indicator, but their function is
   identical to primary tabs.

   .. tabs::

       .. tab:: Declarative KV style

           .. code-block:: python

               from kivy.lang import Builder

               from kivymd.app import MDApp
               from kivymd.uix.tab import (
                   MDTabsItemIcon,
                   MDTabsItemText,
                   MDTabsBadge, MDTabsItemSecondary,
               )

               KV = '''
               MDScreen:
                   md_bg_color: self.theme_cls.backgroundColor

                   MDTabsSecondary:
                       id: tabs
                       pos_hint: {"center_x": .5, "center_y": .5}

                       MDDivider:
               '''


               class Example(MDApp):
                   def on_start(self):
                       for tab_icon, tab_name in {
                           "airplane": "Flights",
                           "treasure-chest": "Trips",
                           "compass-outline": "Explore",
                       }.items():
                           if tab_icon == "treasure-chest":
                               self.root.ids.tabs.add_widget(
                                   MDTabsItemSecondary(
                                       MDTabsItemIcon(
                                           icon=tab_icon,
                                       ),
                                       MDTabsItemText(
                                           text=tab_name,
                                       ),
                                       MDTabsBadge(
                                           text="5",
                                       ),
                                   )
                               )
                           else:
                               self.root.ids.tabs.add_widget(
                                   MDTabsItemSecondary(
                                       MDTabsItemIcon(
                                           icon=tab_icon,
                                       ),
                                       MDTabsItemText(
                                           text=tab_name,
                                       ),
                                   )
                               )
                       self.root.ids.tabs.switch_tab(icon="airplane")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return Builder.load_string(KV)


               Example().run()

       .. tab:: Declarative Python style

           .. code-block:: python

               from kivymd.app import MDApp
               from kivymd.uix.divider import MDDivider
               from kivymd.uix.screen import MDScreen
               from kivymd.uix.tab import (
                   MDTabsItemIcon,
                   MDTabsItemText,
                   MDTabsBadge,
                   MDTabsSecondary,
                   MDTabsItemSecondary,
               )


               class Example(MDApp):
                   def on_start(self):
                       for tab_icon, tab_name in {
                           "airplane": "Flights",
                           "treasure-chest": "Trips",
                           "compass-outline": "Explore",
                       }.items():
                           if tab_icon == "treasure-chest":
                               self.root.get_ids().tabs.add_widget(
                                   MDTabsItemSecondary(
                                       MDTabsItemIcon(
                                           icon=tab_icon,
                                       ),
                                       MDTabsItemText(
                                           text=tab_name,
                                       ),
                                       MDTabsBadge(
                                           text="5",
                                       ),
                                   )
                               )
                           else:
                               self.root.get_ids().tabs.add_widget(
                                   MDTabsItemSecondary(
                                       MDTabsItemIcon(
                                           icon=tab_icon,
                                       ),
                                       MDTabsItemText(
                                           text=tab_name,
                                       ),
                                   )
                               )
                       self.root.get_ids().tabs.switch_tab(icon="airplane")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return (
                           MDScreen(
                               MDTabsSecondary(
                                   MDDivider(),
                                   id="tabs",
                                   pos_hint={"center_x": .5, "center_y": .5},
                               ),
                               md_bg_color=self.theme_cls.backgroundColor,
                           )
                       )


               Example().run()

   Anatomy secondary tabs
   ----------------------

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-secondary-anatomy.png
       :align: center

   Related content
   ---------------

   Use tabs to group related content, not sequential content.

   .. tabs::

       .. tab:: Declarative KV style

           .. code-block:: python

               from kivy.lang import Builder

               from kivymd.app import MDApp
               from kivymd.uix.label import MDLabel
               from kivymd.uix.tab import (
                   MDTabsItemIcon,
                   MDTabsItemText,
                   MDTabsItem,
               )

               KV = '''
               MDScreen:
                   md_bg_color: self.theme_cls.backgroundColor

                   MDTabsPrimary:
                       id: tabs
                       pos_hint: {"center_x": .5, "center_y": .5}
                       size_hint_x: .6

                       MDDivider:

                       MDTabsCarousel:
                           id: related_content_container
                           size_hint_y: None
                           height: dp(320)
               '''


               class Example(MDApp):
                   def on_start(self):
                       for tab_icon, tab_name in {
                           "airplane": "Flights",
                           "treasure-chest": "Trips",
                           "compass-outline": "Explore",
                       }.items():
                           self.root.ids.tabs.add_widget(
                               MDTabsItem(
                                   MDTabsItemIcon(
                                       icon=tab_icon,
                                   ),
                                   MDTabsItemText(
                                       text=tab_name,
                                   ),
                               )
                           )
                           self.root.ids.related_content_container.add_widget(
                               MDLabel(
                                   text=tab_name,
                                   halign="center",
                               )
                           )
                           self.root.ids.tabs.switch_tab(icon="airplane")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return Builder.load_string(KV)


               Example().run()

       .. tab:: Declarative Python style

           .. code-block:: python

               from kivymd.material_resources import dp

               from kivymd.app import MDApp
               from kivymd.uix.divider import MDDivider
               from kivymd.uix.label import MDLabel
               from kivymd.uix.screen import MDScreen
               from kivymd.uix.tab import (
                   MDTabsItemIcon,
                   MDTabsItemText,
                   MDTabsPrimary,
                   MDTabsCarousel,
                   MDTabsItem,
               )


               class Example(MDApp):
                   def on_start(self):
                       for tab_icon, tab_name in {
                           "airplane": "Flights",
                           "treasure-chest": "Trips",
                           "compass-outline": "Explore",
                       }.items():
                           self.root.get_ids().tabs.add_widget(
                               MDTabsItem(
                                   MDTabsItemIcon(
                                       icon=tab_icon,
                                   ),
                                   MDTabsItemText(
                                       text=tab_name,
                                   ),
                               )
                           )
                           self.root.get_ids().related_content_container.add_widget(
                               MDLabel(
                                   text=tab_name,
                                   halign="center",
                               )
                           )
                           self.root.get_ids().tabs.switch_tab(icon="airplane")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return (
                           MDScreen(
                               MDTabsPrimary(
                                   MDDivider(),
                                   MDTabsCarousel(
                                       id="related_content_container",
                                       size_hint_y=None,
                                       height=dp(320),
                                   ),
                                   id="tabs",
                                   pos_hint={"center_x": .5, "center_y": .5},
                                   size_hint_x=0.6,
                               ),
                               md_bg_color=self.theme_cls.backgroundColor,
                           )
                       )


               Example().run()

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-primary-related-content.gif
       :align: center

   Behaviors
   =========

   Scrollable tabs
   ---------------

   When a set of tabs cannot fit on screen, use scrollable tabs. Scrollable tabs
   can use longer text labels and a larger number of tabs. They are best used for
   browsing on touch interfaces.

   .. tabs::

       .. tab:: Declarative KV style

           .. code-block:: python

               from kivy.lang import Builder

               from kivymd.app import MDApp
               from kivymd.uix.tab import MDTabsItemText, MDTabsItem

               KV = '''
               MDScreen:
                   md_bg_color: self.theme_cls.backgroundColor

                   MDTabsPrimary:
                       id: tabs
                       pos_hint: {"center_x": .5, "center_y": .5}
                       size_hint_x: .6
                       allow_stretch: False
                       label_only: True

                       MDDivider:
               '''


               class Example(MDApp):
                   def on_start(self):
                       for tab_name in [
                           "Moscow",
                           "Saint Petersburg",
                           "Novosibirsk",
                           "Yekaterinburg",
                           "Kazan",
                           "Nizhny Novgorod",
                           "Chelyabinsk",
                       ]:
                           self.root.ids.tabs.add_widget(
                               MDTabsItem(
                                   MDTabsItemText(
                                       text=tab_name,
                                   ),
                               )
                           )
                       self.root.ids.tabs.switch_tab(text="Moscow")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return Builder.load_string(KV)


               Example().run()

       .. tab:: Declarative Python style

           .. code-block:: python

               from kivymd.app import MDApp
               from kivymd.uix.divider import MDDivider
               from kivymd.uix.screen import MDScreen
               from kivymd.uix.tab import (
                   MDTabsItemText,
                   MDTabsPrimary,
                   MDTabsItem,
               )


               class Example(MDApp):
                   def on_start(self):
                       for tab_name in [
                           "Moscow",
                           "Saint Petersburg",
                           "Novosibirsk",
                           "Yekaterinburg",
                           "Kazan",
                           "Nizhny Novgorod",
                           "Chelyabinsk",
                       ]:
                           self.root.get_ids().tabs.add_widget(
                               MDTabsItem(
                                   MDTabsItemText(
                                       text=tab_name,
                                   ),
                               )
                           )
                       self.root.get_ids().tabs.switch_tab(text="Moscow")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return (
                           MDScreen(
                               MDTabsPrimary(
                                   MDDivider(),
                                   id="tabs",
                                   pos_hint={"center_x": .5, "center_y": .5},
                                   size_hint_x=0.6,
                                   allow_stretch=False,
                                   label_only=True,
                               ),
                               md_bg_color=self.theme_cls.backgroundColor,
                           )
                       )


               Example().run()

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-primary-scrollable-behavior.gif
       :align: center

   Fixed tabs
   ==========

   Fixed tabs display all tabs in a set simultaneously. They are best for
   switching between related content quickly, such as between transportation
   methods in a map. To navigate between fixed tabs, tap an individual tab, or
   swipe left or right in the content area.

   .. tabs::

       .. tab:: Declarative KV style

           .. code-block:: python

               from kivy.lang import Builder

               from kivymd.app import MDApp
               from kivymd.uix.tab import MDTabsItemText, MDTabsItem

               KV = '''
               MDScreen:
                   md_bg_color: self.theme_cls.backgroundColor

                   MDTabsPrimary:
                       id: tabs
                       pos_hint: {"center_x": .5, "center_y": .5}
                       size_hint_x: .6
                       allow_stretch: True
                       label_only: True

                       MDDivider:
               '''


               class Example(MDApp):
                   def on_start(self):
                       for tab_name in [
                           "Moscow", "Saint Petersburg", "Novosibirsk"
                       ]:
                           self.root.ids.tabs.add_widget(
                               MDTabsItem(
                                   MDTabsItemText(
                                       text=tab_name,
                                   ),
                               )
                           )
                       self.root.ids.tabs.switch_tab(text="Moscow")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return Builder.load_string(KV)


               Example().run()

       .. tab:: Declarative Python style

           .. code-block:: python

               from kivymd.app import MDApp
               from kivymd.uix.divider import MDDivider
               from kivymd.uix.screen import MDScreen
               from kivymd.uix.tab import (
                   MDTabsItemText,
                   MDTabsPrimary,
                   MDTabsItem,
               )


               class Example(MDApp):
                   def on_start(self):
                       for tab_name in [
                           "Moscow", "Saint Petersburg", "Novosibirsk"
                       ]:
                           self.root.get_ids().tabs.add_widget(
                               MDTabsItem(
                                   MDTabsItemText(
                                       text=tab_name,
                                   ),
                               )
                           )
                       self.root.get_ids().tabs.switch_tab(text="Moscow")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return (
                           MDScreen(
                               MDTabsPrimary(
                                   MDDivider(),
                                   id="tabs",
                                   pos_hint={"center_x": .5, "center_y": .5},
                                   size_hint_x=0.6,
                                   allow_stretch=True,
                                   label_only=True,
                               ),
                               md_bg_color=self.theme_cls.backgroundColor,
                           )
                       )


               Example().run()

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-primary-fixed-behavior.png
       :align: center

   Tap a tab
   ---------

   Navigate to a tab by tapping on it.


   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-primary-tap-a-tab-behavior.gif
       :align: center

   Swipe within the content area
   -----------------------------

   To navigate between tabs, users can swipe left or right within the content
   area.

   .. image:: https://github.com/HeaTTheatR/KivyMD-data/raw/master/gallery/kivymddoc/tab-primary-swipe-within-content-area-behavior.gif
       :align: center

   Switching tab
   =============

   You can switch tabs by icon name, by tab name, and by tab objects:

   .. code-block:: python

       instance_tabs.switch_tab(icon="airplane")

   .. code-block:: python

       instance_tabs.switch_tab(text="Airplane")

   .. code-block:: python

       instance_tabs.switch_tab(
           instance=instance_tabs_item  # MDTabsItem
       )

   API break
   =========

   1.2.0 version
   -------------

   .. code-block:: python

       from kivy.lang import Builder

       from kivymd.app import MDApp
       from kivymd.uix.floatlayout import MDFloatLayout
       from kivymd.uix.tab import MDTabsBase
       from kivymd.icon_definitions import md_icons

       KV = '''
       MDBoxLayout:

           MDTabs:
               id: tabs
               on_ref_press: app.on_ref_press(*args)


       <Tab>

           MDIconButton:
               id: icon
               icon: app.icons[0]
               icon_size: "48sp"
               pos_hint: {"center_x": .5, "center_y": .5}
       '''


       class Tab(MDFloatLayout, MDTabsBase):
           '''Class implementing content for a tab.'''


       class Example(MDApp):
           icons = list(md_icons.keys())[15:30]

           def build(self):
               return Builder.load_string(KV)

           def on_start(self):
               for name_tab in self.icons:
                   self.root.ids.tabs.add_widget(
                       Tab(title=name_tab, icon=name_tab)
                   )


       Example().run()

   2.0.0 version
   -------------

   .. tabs::

       .. tab:: Declarative KV style

           .. code-block:: python

               from kivy.lang import Builder

               from kivymd.app import MDApp
               from kivymd.icon_definitions import md_icons
               from kivymd.uix.label import MDIcon
               from kivymd.uix.tab import MDTabsItem, MDTabsItemIcon
               from kivymd.uix.tab.tab import MDTabsItemText

               KV = '''
               MDScreen:
                   md_bg_color: self.theme_cls.backgroundColor

                   MDTabsPrimary:
                       id: tabs
                       allow_stretch: False
                       pos_hint: {"center_x": .5, "center_y": .5}

                       MDDivider:

                       MDTabsCarousel:
                           id: related_content
                           size_hint_y: None
                           height: root.height - tabs.ids.tab_scroll.height
               '''


               class Example(MDApp):
                   def on_start(self):
                       for name_tab in list(md_icons.keys())[15:30]:
                           self.root.ids.tabs.add_widget(
                               MDTabsItem(
                                   MDTabsItemIcon(
                                       icon=name_tab,
                                   ),
                                   MDTabsItemText(
                                       text=name_tab,
                                   ),
                               )
                           )
                           self.root.ids.related_content.add_widget(
                               MDIcon(
                                   icon=name_tab,
                                   pos_hint={"center_x": 0.5, "center_y": 0.5},
                               )
                           )
                           self.root.ids.tabs.switch_tab(icon="airplane")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return Builder.load_string(KV)


               Example().run()

       .. tab:: Declarative Python style

           .. code-block:: python

               from kivymd.app import MDApp
               from kivymd.uix.divider import MDDivider
               from kivymd.uix.label import MDIcon
               from kivymd.uix.screen import MDScreen
               from kivymd.uix.tab import (
                   MDTabsItemIcon,
                   MDTabsItemText,
                   MDTabsPrimary,
                   MDTabsCarousel,
                   MDTabsItem,
               )


               class Example(MDApp):
                   def on_start(self):
                       tabs = self.root.get_ids().tabs
                       related_content = self.root.get_ids().related_content
                       related_content.height = (
                           self.root.height - tabs.ids.tab_scroll.height
                       )

                       for name_tab in list(md_icons.keys())[15:30]:
                           tabs.add_widget(
                               MDTabsItem(
                                   MDTabsItemIcon(
                                       icon=name_tab,
                                   ),
                                   MDTabsItemText(
                                       text=name_tab,
                                   ),
                               )
                           )
                           related_content.add_widget(
                               MDIcon(
                                   icon=name_tab,
                                   pos_hint={"center_x": 0.5, "center_y": 0.5},
                               )
                           )
                           tabs.switch_tab(icon="airplane")

                   def build(self):
                       self.theme_cls.primary_palette = "Olive"
                       return MDScreen(
                           MDTabsPrimary(
                               MDDivider(),
                               MDTabsCarousel(
                                   id="related_content",
                                   size_hint_y=None,
                               ),
                               id="tabs",
                               pos_hint={"center_x": 0.5, "center_y": 0.5},
                               allow_stretch=False,
                           ),
                           md_bg_color=self.theme_cls.backgroundColor,
                       )


               Example().run()


API - :mod:`kivymd.uix.tab.tab`
-------------------------------

.. py:class:: MDTabsBadge(*args, **kwargs)




   Implements an badge for secondary tabs.

   .. versionadded:: 2.0.0

   For more information, see in the
   :class:`~kivymd.uix.badge.badge.MDBadge` class documentation.


.. py:class:: MDTabsCarousel(*args, **kwargs)




   Implements a carousel for user-generated content.

   For more information, see in the
   :class:`~kivy.uix.carousel.Carousel` class documentation.

   .. py:attribute:: lock_swiping

      If True - disable switching tabs by swipe.

      :attr:`lock_swiping` is an :class:`~kivy.properties.BooleanProperty`
      and defaults to `False`.


   .. py:method:: on_touch_move(touch) -> str | bool | None

      Receive a touch move event. The touch is in parent coordinates.

      See :meth:`on_touch_down` for more information.


   .. py:method:: add_widget(widget, *args, **kwargs)

      Add a new widget as a child of this widget.

          :Parameters:
              `widget`: :class:`Widget`
                  Widget to add to our list of children.
              `index`: int, defaults to 0
                  Index to insert the widget in the list. Notice that the default
                  of 0 means the widget is inserted at the beginning of the list
                  and will thus be drawn on top of other sibling widgets. For a
                  full discussion of the index and widget hierarchy, please see
                  the :doc:`Widgets Programming Guide <guide/widgets>`.

                  .. versionadded:: 1.0.5
              `canvas`: str, defaults to None
                  Canvas to add widget's canvas to. Can be 'before', 'after' or
                  None for the default canvas.

                  .. versionadded:: 1.9.0

      .. code-block:: python

          >>> from kivy.uix.button import Button
          >>> from kivy.uix.slider import Slider
          >>> root = Widget()
          >>> root.add_widget(Button())
          >>> slider = Slider()
          >>> root.add_widget(slider)

          



.. py:class:: MDTabsItemText(*args, **kwargs)




   Implements an label for the :class:`~MDTabsItem` class.

   For more information, see in the
   :class:`~kivymd.uix.label.label.MDLabel` class documentation.

   .. versionadded:: 2.0.0


.. py:class:: MDTabsItemIcon(*args, **kwargs)




   Implements an icon for the :class:`~MDTabsItem` class.

   For more information, see in the
   :class:`~kivymd.uix.label.label.MDIcon` class documentation.

   .. versionadded:: 2.0.0


.. py:class:: MDTabsItem(*args, **kwargs)




   Implements a item with an icon and text for :class:`~MDTabsPrimary` class.

   .. versionadded:: 2.0.0

   For more information, see in the
   :class:`~MDTabsItemBase` and
   :class:`~kivy.uix.boxlayout.BoxLayout`
   classes documentation.

   .. py:method:: add_widget(widget, *args, **kwargs)

      Add a new widget as a child of this widget.

          :Parameters:
              `widget`: :class:`Widget`
                  Widget to add to our list of children.
              `index`: int, defaults to 0
                  Index to insert the widget in the list. Notice that the default
                  of 0 means the widget is inserted at the beginning of the list
                  and will thus be drawn on top of other sibling widgets. For a
                  full discussion of the index and widget hierarchy, please see
                  the :doc:`Widgets Programming Guide <guide/widgets>`.

                  .. versionadded:: 1.0.5
              `canvas`: str, defaults to None
                  Canvas to add widget's canvas to. Can be 'before', 'after' or
                  None for the default canvas.

                  .. versionadded:: 1.9.0

      .. code-block:: python

          >>> from kivy.uix.button import Button
          >>> from kivy.uix.slider import Slider
          >>> root = Widget()
          >>> root.add_widget(Button())
          >>> slider = Slider()
          >>> root.add_widget(slider)

          



.. py:class:: MDTabsPrimary(*args, **kwargs)




   Tabs primary class.

   .. versionchanged:: 2.0.0

       Rename from `MDTabs` to `MDTabsPrimary` class.

   For more information, see in the
   :class:`~kivymd.uix.behaviors.declarative_behavior.DeclarativeBehavior` and
   :class:`~kivymd.theming.ThemableBehavior` and
   :class:`~kivy.uix.boxlayout.BoxLayout`
   classes documentation.

   :Events:
       `on_tab_switch`
           Fired when switching tabs.

   .. py:attribute:: md_bg_color

      The background color of the widget.

      :attr:`md_bg_color` is an :class:`~kivy.properties.ColorProperty`
      and defaults to `None`.


   .. py:attribute:: label_only

      Tabs with a label only or with an icon and a label.

      .. versionadded:: 2.0.0

      :attr:`label_only` is an :class:`~kivy.properties.BooleanProperty`
      and defaults to `False`.


   .. py:attribute:: allow_stretch

      Whether to stretch tabs to the width of the panel.

      :attr:`allow_stretch` is an :class:`~kivy.properties.BooleanProperty`
      and defaults to `True`.


   .. py:attribute:: lock_swiping

      If True - disable switching tabs by swipe.

      :attr:`lock_swiping` is an :class:`~kivy.properties.BooleanProperty`
      and defaults to `False`.


   .. py:attribute:: anim_duration

      Duration of the slide animation.

      :attr:`anim_duration` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `0.2`.


   .. py:attribute:: indicator_anim

      Tab indicator animation. If you want use animation set it to ``True``.

      .. versionchanged:: 2.0.0

          Rename from `tab_indicator_anim` to `indicator_anim` attribute.

      :attr:`indicator_anim` is an :class:`~kivy.properties.BooleanProperty`
      and defaults to `True`.


   .. py:attribute:: indicator_radius

      Radius of the tab indicator.

      .. versionadded:: 2.0.0

      :attr:`indicator_radius` is an :class:`~kivy.properties.VariableListProperty`
      and defaults to `[dp(2), dp(2), 0, 0]`.


   .. py:attribute:: indicator_height

      Height of the tab indicator.

      .. versionchanged:: 2.0.0

          Rename from `tab_indicator_height` to `indicator_height` attribute.

      :attr:`indicator_height` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `'4dp'`.


   .. py:attribute:: indicator_duration

      The duration of the animation of the indicator movement when switching
      tabs.

      .. versionadded:: 2.0.0

      :attr:`indicator_duration` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `0.5`.


   .. py:attribute:: indicator_transition

      The transition name of animation of the indicator movement when switching
      tabs.

      .. versionadded:: 2.0.0

      :attr:`indicator_transition` is an :class:`~kivy.properties.StringProperty`
      and defaults to `'out_expo'.


   .. py:attribute:: last_scroll_x

      Is the carousel reference of the next tab/slide.
      When you go from `'Tab A'` to `'Tab B'`, `'Tab B'` will be the
      target tab/slide of the carousel.

      :attr:`last_scroll_x` is an :class:`~kivy.properties.AliasProperty`.


   .. py:attribute:: target

      It is the carousel reference of the next tab / slide.
      When you go from `'Tab A'` to `'Tab B'`, `'Tab B'` will be the
      target tab / slide of the carousel.

      :attr:`target` is an :class:`~kivy.properties.ObjectProperty`
      and default to `None`.


   .. py:attribute:: indicator

      It is the :class:`~kivy.graphics.vertex_instructions.SmoothRoundedRectangle`
      instruction reference of the tab indicator.

      :attr:`indicator` is an :class:`~kivy.properties.AliasProperty`.


   .. py:method:: get_last_scroll_x()


   .. py:method:: get_rect_instruction()


   .. py:method:: add_widget(widget, *args, **kwargs)

      Add a new widget as a child of this widget.

          :Parameters:
              `widget`: :class:`Widget`
                  Widget to add to our list of children.
              `index`: int, defaults to 0
                  Index to insert the widget in the list. Notice that the default
                  of 0 means the widget is inserted at the beginning of the list
                  and will thus be drawn on top of other sibling widgets. For a
                  full discussion of the index and widget hierarchy, please see
                  the :doc:`Widgets Programming Guide <guide/widgets>`.

                  .. versionadded:: 1.0.5
              `canvas`: str, defaults to None
                  Canvas to add widget's canvas to. Can be 'before', 'after' or
                  None for the default canvas.

                  .. versionadded:: 1.9.0

      .. code-block:: python

          >>> from kivy.uix.button import Button
          >>> from kivy.uix.slider import Slider
          >>> root = Widget()
          >>> root.add_widget(Button())
          >>> slider = Slider()
          >>> root.add_widget(slider)

          


   .. py:method:: do_autoscroll_tabs(instance: MDTabsItem, value: float) -> None

      Automatically scrolls the list of tabs when swiping the carousel
      slide (related content).

      .. versionchanged:: 2.0.0

          Rename from `tab_bar_autoscroll` to `do_autoscroll_tabs` method.


   .. py:method:: android_animation(instance: MDTabsCarousel, offset: float) -> None

      Fired when swiping a carousel slide (related content).


   .. py:method:: update_indicator(x: float = 0.0, w: float = 0.0, instance: MDTabsItem = None) -> None

      Update position and size of the indicator.


   .. py:method:: switch_tab(instance: MDTabsItem = None, text: str = '', icon: str = '') -> None

      Switches tabs by tab object/tab text/tab icon name.


   .. py:method:: set_active_item(item: MDTabsItem) -> None

      Sets the active tab item.


   .. py:method:: get_tabs_list() -> list

      Returns a list of :class:`~MDTabsItem` objects.

      .. versionchanged:: 2.0.0

          Rename from `get_tab_list` to `get_tabs_list` method.


   .. py:method:: get_slides_list() -> list

      Returns a list of user tab objects.

      .. versionchanged:: 2.0.0

          Rename from `get_slides` to `get_slides_list` method.


   .. py:method:: get_current_tab() -> MDTabsItem

      Returns current tab object.

      .. versionadded:: 1.0.0


   .. py:method:: get_current_related_content() -> kivy.uix.widget.Widget

      Returns the carousel slide object (related content).

      .. versionadded:: 2.0.0


   .. py:method:: on_tab_switch(*args) -> None

      This event is launched every time the current tab is changed.


   .. py:method:: on_slide_progress(*args) -> None

      This event is deployed every available frame while the tab is
      scrolling.


   .. py:method:: on_carousel_index(instance: MDTabsCarousel, value: int) -> None

      Fired when the Tab index have changed.
      This event is deployed by the builtin carousel of the class.


   .. py:method:: on_size(instance, size) -> None

      Fired when the application screen size changes.


   .. py:method:: recalculate_tab_widths() -> None

      Recalculates and updates the width of each tab in the tab bar.

      This method ensures that all tabs are evenly distributed across the
      available horizontal space when `allow_stretch` is enabled. It is
      automatically called after a new tab is added.

      If no tabs are present, the method exits without making changes.



.. py:class:: MDTabsItemSecondary(*args, **kwargs)




   Implements a item with an icon and text for :class:`~MDTabsSecondary`
   class.

   .. versionadded:: 2.0.0

   For more information, see in the
   :class:`~MDTabsItemBase` and
   :class:`~kivy.uix.anchorlayout.AnchorLayout`
   classes documentation.

   .. py:method:: add_widget(widget, *args, **kwargs)

      Add a new widget as a child of this widget.

          :Parameters:
              `widget`: :class:`Widget`
                  Widget to add to our list of children.
              `index`: int, defaults to 0
                  Index to insert the widget in the list. Notice that the default
                  of 0 means the widget is inserted at the beginning of the list
                  and will thus be drawn on top of other sibling widgets. For a
                  full discussion of the index and widget hierarchy, please see
                  the :doc:`Widgets Programming Guide <guide/widgets>`.

                  .. versionadded:: 1.0.5
              `canvas`: str, defaults to None
                  Canvas to add widget's canvas to. Can be 'before', 'after' or
                  None for the default canvas.

                  .. versionadded:: 1.9.0

      .. code-block:: python

          >>> from kivy.uix.button import Button
          >>> from kivy.uix.slider import Slider
          >>> root = Widget()
          >>> root.add_widget(Button())
          >>> slider = Slider()
          >>> root.add_widget(slider)

          



.. py:class:: MDTabsSecondary(*args, **kwargs)




   Tabs secondary class.

   .. versionadded:: 2.0.0

   For more information, see in the
   :class:`~MDTabsPrimary` class documentation.

   .. py:attribute:: indicator_radius

      Radius of the tab indicator.

      :attr:`indicator_radius` is an :class:`~kivy.properties.VariableListProperty`
      and defaults to `[0, 0, 0, 0]`.


   .. py:attribute:: indicator_height

      Height of the tab indicator.

      :attr:`indicator_height` is an :class:`~kivy.properties.NumericProperty`
      and defaults to `'2dp'`.




