ion-tab-button
A tab button is a UI component that is placed inside of a tab bar. The tab button can specify the layout of the icon and label and connect to a tab view.
See the tabs documentation for more details on configuring tabs.
Usage
- Angular
- Javascript
- React
- Vue
<ion-tabs>
<!-- Tab bar -->
<ion-tab-barslot="bottom">
<ion-tab-buttontab="schedule">
<ion-iconname="calendar"></ion-icon>
<ion-label>Schedule</ion-label>
</ion-tab-button>
<ion-tab-buttontab="speakers">
<ion-iconname="person-circle"></ion-icon>
<ion-label>Speakers</ion-label>
</ion-tab-button>
<ion-tab-buttontab="map">
<ion-iconname="map"></ion-icon>
<ion-label>Map</ion-label>
</ion-tab-button>
<ion-tab-buttontab="about">
<ion-iconname="information-circle"></ion-icon>
<ion-label>About</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
<ion-tabs>
<!-- Tab views -->
<ion-tabtab="schedule">
<ion-router-outletname="schedule"></ion-router-outlet>
</ion-tab>
<ion-tabtab="speakers">
<ion-router-outletname="speakers"></ion-router-outlet>
</ion-tab>
<ion-tabtab="map">
<ion-router-outletname="map"></ion-router-outlet>
</ion-tab>
<ion-tabtab="about">
<ion-router-outletname="about"></ion-router-outlet>
</ion-tab>
<!-- Tab bar -->
<ion-tab-barslot="bottom">
<ion-tab-buttontab="schedule"href="/app/tabs/(schedule:schedule)">
<ion-iconname="calendar"></ion-icon>
<ion-label>Schedule</ion-label>
</ion-tab-button>
<ion-tab-buttontab="speakers"href="/app/tabs/(speakers:speakers)">
<ion-iconname="person-circle"></ion-icon>
<ion-label>Speakers</ion-label>
</ion-tab-button>
<ion-tab-buttontab="map"href="/app/tabs/(map:map)">
<ion-iconname="map"></ion-icon>
<ion-label>Map</ion-label>
</ion-tab-button>
<ion-tab-buttontab="about"href="/app/tabs/(about:about)">
<ion-iconname="information-circle"></ion-icon>
<ion-label>About</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
importReactfrom'react';
import{IonTabs,IonTabBar,IonTabButton,IonIcon,IonLabel,IonContent}from'@ionic/react';
import{ calendar, personCircle, map, informationCircle }from'ionicons/icons';
exportconstTabButtonExample:React.FC=()=>(
<IonContent>
<IonTabs>
{/*-- Tab bar --*/}
<IonTabBarslot="bottom">
<IonTabButtontab="schedule">
<IonIconicon={calendar}/>
<IonLabel>Schedule</IonLabel>
</IonTabButton>
<IonTabButtontab="speakers">
<IonIconicon={personCircle}/>
<IonLabel>Speakers</IonLabel>
</IonTabButton>
<IonTabButtontab="map">
<IonIconicon={map}/>
<IonLabel>Map</IonLabel>
</IonTabButton>
<IonTabButtontab="about">
<IonIconicon={informationCircle}/>
<IonLabel>About</IonLabel>
</IonTabButton>
</IonTabBar>
</IonTabs>
</IonContent>
);
<template>
<ion-tabs>
<!-- Tab bar -->
<ion-tab-barslot="bottom">
<ion-tab-buttontab="schedule"href="/tabs/schedule">
<ion-icon:icon="calendar"></ion-icon>
<ion-label>Schedule</ion-label>
</ion-tab-button>
<ion-tab-buttontab="speakers"href="/tabs/speakers">
<ion-icon:icon="person-circle"></ion-icon>
<ion-label>Speakers</ion-label>
</ion-tab-button>
<ion-tab-buttontab="map"href="/tabs/map">
<ion-icon:icon="map"></ion-icon>
<ion-label>Map</ion-label>
</ion-tab-button>
<ion-tab-buttontab="about"href="/tabs/about">
<ion-icon:icon="informationCircle"></ion-icon>
<ion-label>About</ion-label>
</ion-tab-button>
</ion-tab-bar>
</ion-tabs>
</template>
<script>
import{IonIcon,IonLabel,IonTabBar,IonTabButton,IonTabs}from'@ionic/vue';
import{ calendar, informationCircle, map, personCircle }from'ionicons/icons';
import{ defineComponent }from'vue';
exportdefaultdefineComponent({
components:{
IonIcon,
IonLabel,
IonTabBar,
IonTabButton,
IonTabs,
},
setup(){
return{ calendar, informationCircle, map, personCircle };
},
});
</script>
Properties
disabled
Description If
true, the user cannot interact with the tab button. Attribute
disabled Type
boolean Default
falsedownload
Description This attribute instructs browsers to download a URL instead of navigating to it, so the user will be prompted to save it as a local file. If the attribute has a value, it is used as the pre-filled file name in the Save prompt (the user can still change the file name if they want).
Attribute
download Type
string | undefined Default
undefinedhref
Description Contains a URL or a URL fragment that the hyperlink points to. If this property is set, an anchor tag will be rendered.
Attribute
href Type
string | undefined Default
undefinedlayout
Description Set the layout of the text and icon in the tab bar. It defaults to
'icon-top'. Attribute
layout Type
"icon-bottom" | "icon-end" | "icon-hide" | "icon-start" | "icon-top" | "label-hide" | undefined Default
undefinedmode
Description The mode determines which platform styles to use.
Attribute
mode Type
"ios" | "md" Default
undefinedrel
Description Specifies the relationship of the target object to the link object. The value is a space-separated list of link types.
Attribute
rel Type
string | undefined Default
undefinedselected
Description The selected tab component
Attribute
selected Type
boolean Default
falsetab
Description A tab id must be provided for each
ion-tab. It's used internally to reference the selected tab or by the router to switch between them. Attribute
tab Type
string | undefined Default
undefinedtarget
Description Specifies where to display the linked URL. Only applies when an
href is provided. Special keywords: "_blank", "_self", "_parent", "_top". Attribute
target Type
string | undefined Default
undefinedEvents
No events available for this component.
Methods
No public methods available for this component.
CSS Shadow Parts
| Name | Description |
|---|---|
native | The native HTML anchor element that wraps all child elements. |
CSS Custom Properties
| Name | Description |
|---|---|
--background | Background of the tab button |
--background-focused | Background of the tab button when focused with the tab key |
--background-focused-opacity | Opacity of the tab button background when focused with the tab key |
--color | Color of the tab button |
--color-focused | Color of the tab button when focused with the tab key |
--color-selected | Color of the selected tab button |
--padding-bottom | Bottom padding of the tab button |
--padding-end | Right padding if direction is left-to-right, and left padding if direction is right-to-left of the tab button |
--padding-start | Left padding if direction is left-to-right, and right padding if direction is right-to-left of the tab button |
--padding-top | Top padding of the tab button |
--ripple-color | Color of the button ripple effect |
Slots
No slots available for this component.