# Tabs > Create a widget of tabbable panes of _local content_. The tabs component is built upon navs and > cards internally, and provides full keyboard navigation control of the tabs. For navigation based tabs (i.e. tabs that would change the URL), use the [``](/docs/components/nav) component instead. ## Basic usage ```html

I'm the first tab

I'm the second tab

I'm a disabled tab!

``` **Tip:** You should supply each child `` component a unique `key` value if dynamically adding or removing `` components (i.e. `v-if` or for loops). The `key` attribute is a special Vue attribute, see https://vuejs.org/v2/api/#key. ## Cards integration Tabs support integrating with Bootstrap cards. Just add the `card` property to `` and place it inside a `` component. Note that you should add the`no-body` prop on the `` component in order to properly decorate the card header and remove the extra padding introduced by `card-body`. ```html
Tab contents 1 Tab contents 2
``` When `` is in `card` mode, each `` sub-component will automatically have the `card-body` class applied (this class provides the padding around the tab content). To disable the `card-body` class, set the `no-body` prop on the `` sub component. ```html
Picture 1 footer Picture 2 footer Picture 3 footer This tab does not have the no-body prop set Quis magna Lorem anim amet ipsum do mollit sit cillum voluptate ex nulla tempor. Laborum consequat non elit enim exercitation cillum aliqua consequat id aliqua. Esse ex consectetur mollit voluptate est in duis laboris ad sit ipsum anim Lorem. Incididunt veniam velit elit elit veniam Lorem aliqua quis ullamco deserunt sit enim elit aliqua esse irure.
``` **Note:** Setting the `no-body` prop on `` will have no affect when `` is not in `card` mode (as the `card-body` class is only set when in `card` mode). Refer to the [Cards documentation](/docs/components/card) for more details on card components. ## Pills variant Tabs use the `tabs` styling by default. Just add `pills` property to `` for the pill style variant. ```html
Tab contents 1 Tab contents 2
``` ## Fill and justify Force your `` controls to extend the full available width. ### Fill To proportionately fill all available space with your tab controls, set the `fill` prop. Notice that all horizontal space is occupied, but not every control has the same width. ```html

I'm the first tab

I'm the second tab

I'm the tab with the very, very long title

I'm a disabled tab!

``` ### Justified For equal-width controls, use the `justified` prop instead. All horizontal space will be occupied by the controls, but unlike using `fill` above, every control will be the same width. ```html

I'm the first tab

I'm the second tab

I'm the tab with the very, very long title

I'm a disabled tab!

``` ## Alignment To align your tab controls, use the `align` prop. Available values are `left`, `center` and `right`. ```html

I'm the first tab

I'm the second tab

I'm a disabled tab!

``` ## Bottom placement of tab controls Visually move the tab controls to the bottom by setting the prop `end`. ```html
Tab contents 1 Tab contents 2
``` **Caveats:** - Bottom placement visually works best with the `pills` variant. When using the default `tabs` variant, you may want to provided your own custom styling classes, as Bootstrap v4 CSS assumes the tabs will always be placed on the top of the tabs content. - To provide a better user experience with bottom placed controls, ensure that the content of each tab pane is the same height and fits completely within the visible viewport, otherwise the user will need to scroll up to read the start of the tabbed content. ## Vertical tabs Have the tab controls placed on the lefthand side by setting the `vertical` prop to `true`. Vertical tabs work with or without `card` mode enabled. ```html
Tab contents 1 Tab contents 2 Tab contents 3
``` Visually move the tab controls to the right hand side by setting the `end` prop: ```html
Tab contents 1 Tab contents 2 Tab contents 3
``` The width of the vertical tab controls will expand to fit the width of the tab title. To control the width, set a [width utility class](/docs/reference/size-props#sizing-utility-classes) via the prop `nav-wrapper-class`. You can use values such as `w-25` (25% width), `w-50` (50% width), etc., or column classes such as `col-2`, `col-3`, etc. ```html
Tab contents 1 Tab contents 2 Tab contents 3
``` Vertical placement visually works best with the `pills` variant. When using the default `tabs` variant, you may want to provided your own custom styling classes, as Bootstrap v4 CSS assumes the tab controls will always be placed on the top of the tabs content. **Note:** _overflowing text may occur if your width is narrower than the tab title. You may need additional custom styling._ ## Active classes To apply classes to the currently active control or tab use the `active-nav-item-class` and `active-tab-class` props. ```html

I'm the first tab

I'm the second tab

I'm a disabled tab!

``` ## Fade animation Fade is enabled by default when changing tabs. It can disabled with `no-fade` property. ## Add tabs without content If you want to add extra tabs that do not have any content, you can put them in `tabs-start` or `tabs-end` slot(s): ```html
``` Use the `tabs-start` slot to place extra tab buttons before the content tab buttons, and use the `tabs-end` slot to place extra tab buttons after the content tab buttons. **Note:** extra (contentless) tab buttons should be a `` or have a root element of `
  • ` and class `nav-item` for proper rendering and semantic markup. ## Add custom content to tab title If you want to add custom content to tab title, like HTML code, icons, or another non-interactive Vue component, this possible by using `title` slot of ``. ```html

    Tab contents 1

    Tab contents 2

    ``` **Do not** place interactive elements/components inside the title slot. The tab button is a link which does not support child interactive elements per the HTML5 spec. ## Apply custom classes to the generated nav-tabs or pills The tab selectors are based on Bootstrap v4's `nav` markup ( i.e. `ul.nav > li.nav-item > a.nav-link`). In some situations, you may want to add classes to the `
  • ` (nav-item) and/or the `` (nav-link) on a per tab basis. To do so, simply supply the classname to the `title-item-class` prop (for the `
  • ` element) or `title-link-class` prop (for the `` element). Value's can be passed as a string or array of strings. **Note:** _The `active` class is automatically applied to the active tabs `` element. You may need to accommodate your custom classes for this._ ```html ``` ## Lazy loading tab content Sometimes it's preferred to load components & data only when activating a tab, instead of loading all tabs (and associated data) when rendering the `` set. Individual `` components can be lazy loaded via the `lazy` prop, which when set doesn't mount the content of the `` until it is activated (shown), and will be un-mounted when the tab is deactivated (hidden): ```html I'm always mounted I'm lazy mounted! ``` One can also make all tab's lazy by setting the `lazy` prop on the parent `` component: ```html I'm lazy mounted! I'm lazy mounted too! ``` ## Keyboard navigation Keyboard navigation is enabled by default for ARIA compliance with tablists when a tab button has focus. | Keypress | Action | | --------------------------------------------------------------------- | ---------------------------------------------- | | Left or Up | Activate the previous non-disabled tab | | Right or Down | Activate the next non-disabled tab | | Shift+Left or Shift+Up | Activate the first non-disabled tab | | Home | Activate the first non-disabled tab | | Shift+Right or Shift+Down | Activate the last non-disabled tab | | End | Activate the last non-disabled tab | | Tab | Move focus to the active tab content | | Shift+Tab | Move focus to the previous control on the page | Disable keyboard navigation by setting the prop `no-key-nav`. Behavior will now default to regular browser navigation with TAB key. | Keypress | Action | | ------------------------------------ | ------------------------------------------------------ | | Tab | Move to the next tab button or control on the page | | Shift+Tab | Move to the previous tab button or control on the page | | Enter or Space | Activate current focused button's tab | ## Programmatically activating and deactivating tabs Use the `` `v-model` to control which tab is active by setting the `v-model` to the index (zero-based) of the tab to be shown (see example below). Alternatively, you can use the `active` prop on each `` with the `.sync` modifier to activate the tab, or to detect if a particular tab is active. Each `` instance also provides two public methods to activate or deactivate the tab. The methods are `.activate()` and `.deactivate()`, respectively. If activation or deactivation fails (i.e. a tab is disabled or no tab is available to move activation to), then the currently active tab will remain active and the method will return `false`. You will need a reference to the `` in order to use these methods. ## Preventing a `` from being activated To prevent a tab from activating, simply set the `disabled` prop on the `` component. Alternatively, you can listen for the `activate-tab` event, which provides an option to prevent the tab from activating. The `activate-tab` event is emitted with three arguments: - `newTabIndex`: The index of the tab that is going to be activated - `prevTabIndex`: The index of the currently active tab - `bvEvent`: The `BvEvent` object. Call `bvEvent.preventDefault()` to prevent `newTabIndex` from being activated For accessibility reasons, when using the `activate-tab` event to prevent a tab from activating, you should provide some means of notification to the user as to why the tab is not able to be activated. It is recommended to use the `disabled` attribute on the `` component instead of using the `activate-tab` event (as `disabled` is more intuitive for screen reader users). ## Advanced examples ### External controls using `v-model` ```html ``` ### Dynamic tabs + tabs-end slot ```html ```