You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Segment buttons are groups of related buttons inside of a Segment. They are displayed in a horizontal row. A segment button can be checked by default by adding the checked attribute or by setting the value of the segment to the value of the segment button. Only one segment button should be selected at a time.
Usage
Angular
<!-- Segment buttons with text and click listeners --><ion-segment><ion-segment-button(ionSelect)="segmentButtonClicked($event)"><ion-label>Friends</ion-label></ion-segment-button><ion-segment-button(ionSelect)="segmentButtonClicked($event)"><ion-label>Enemies</ion-label></ion-segment-button></ion-segment><!-- Segment buttons with the first checked and the last disabled --><ion-segment><ion-segment-buttonchecked><ion-label>Paid</ion-label></ion-segment-button><ion-segment-button><ion-label>Free</ion-label></ion-segment-button><ion-segment-buttondisabled><ion-label>Top</ion-label></ion-segment-button></ion-segment><!-- Segment buttons with values and icons --><ion-segment><ion-segment-buttonvalue="camera"><ion-iconname="camera"></ion-icon></ion-segment-button><ion-segment-buttonvalue="bookmark"><ion-iconname="bookmark"></ion-icon></ion-segment-button></ion-segment><!-- Segment with a value that checks the last button --><ion-segmentvalue="shared"><ion-segment-buttonvalue="bookmarks"><ion-label>Bookmarks</ion-label></ion-segment-button><ion-segment-buttonvalue="reading"><ion-label>Reading List</ion-label></ion-segment-button><ion-segment-buttonvalue="shared"><ion-label>Shared Links</ion-label></ion-segment-button></ion-segment><!-- Label only --><ion-segment><ion-segment-buttonchecked><ion-label>Item One</ion-label></ion-segment-button><ion-segment-button><ion-label>Item Two</ion-label></ion-segment-button><ion-segment-button><ion-label>Item Three</ion-label></ion-segment-button></ion-segment><!-- Icon only --><ion-segment><ion-segment-button><ion-iconname="call"></ion-icon></ion-segment-button><ion-segment-buttonchecked><ion-iconname="heart"></ion-icon></ion-segment-button><ion-segment-button><ion-iconname="pin"></ion-icon></ion-segment-button></ion-segment><!-- Icon top --><ion-segment><ion-segment-button><ion-label>Item One</ion-label><ion-iconname="call"></ion-icon></ion-segment-button><ion-segment-buttonchecked><ion-label>Item Two</ion-label><ion-iconname="heart"></ion-icon></ion-segment-button><ion-segment-button><ion-label>Item Three</ion-label><ion-iconname="pin"></ion-icon></ion-segment-button></ion-segment><!-- Icon bottom --><ion-segment><ion-segment-buttoncheckedlayout="icon-bottom"><ion-iconname="call"></ion-icon><ion-label>Item One</ion-label></ion-segment-button><ion-segment-buttonlayout="icon-bottom"><ion-iconname="heart"></ion-icon><ion-label>Item Two</ion-label></ion-segment-button><ion-segment-buttonlayout="icon-bottom"><ion-iconname="pin"></ion-icon><ion-label>Item Three</ion-label></ion-segment-button></ion-segment><!-- Icon start --><ion-segment><ion-segment-buttoncheckedlayout="icon-start"><ion-label>Item One</ion-label><ion-iconname="call"></ion-icon></ion-segment-button><ion-segment-buttonlayout="icon-start"><ion-label>Item Two</ion-label><ion-iconname="heart"></ion-icon></ion-segment-button><ion-segment-buttonlayout="icon-start"><ion-label>Item Three</ion-label><ion-iconname="pin"></ion-icon></ion-segment-button></ion-segment><!-- Icon end --><ion-segment><ion-segment-buttoncheckedlayout="icon-end"><ion-iconname="call"></ion-icon><ion-label>Item One</ion-label></ion-segment-button><ion-segment-buttondisabledlayout="icon-end"><ion-iconname="heart"></ion-icon><ion-label>Item Two</ion-label></ion-segment-button><ion-segment-buttonlayout="icon-end"><ion-iconname="pin"></ion-icon><ion-label>Item Three</ion-label></ion-segment-button></ion-segment>
<!-- Segment buttons with text --><ion-segment><ion-segment-button><ion-label>Friends</ion-label></ion-segment-button><ion-segment-button><ion-label>Enemies</ion-label></ion-segment-button></ion-segment><!-- Segment buttons with the first checked and the last disabled --><ion-segment><ion-segment-buttonchecked><ion-label>Paid</ion-label></ion-segment-button><ion-segment-button><ion-label>Free</ion-label></ion-segment-button><ion-segment-buttondisabled><ion-label>Top</ion-label></ion-segment-button></ion-segment><!-- Segment buttons with values and icons --><ion-segment><ion-segment-buttonvalue="camera"><ion-iconname="camera"></ion-icon></ion-segment-button><ion-segment-buttonvalue="bookmark"><ion-iconname="bookmark"></ion-icon></ion-segment-button></ion-segment><!-- Segment with a value that checks the last button --><ion-segmentvalue="shared"><ion-segment-buttonvalue="bookmarks"><ion-label>Bookmarks</ion-label></ion-segment-button><ion-segment-buttonvalue="reading"><ion-label>Reading List</ion-label></ion-segment-button><ion-segment-buttonvalue="shared"><ion-label>Shared Links</ion-label></ion-segment-button></ion-segment><!-- Label only --><ion-segment><ion-segment-buttonchecked><ion-label>Item One</ion-label></ion-segment-button><ion-segment-button><ion-label>Item Two</ion-label></ion-segment-button><ion-segment-button><ion-label>Item Three</ion-label></ion-segment-button></ion-segment><!-- Icon only --><ion-segment><ion-segment-button><ion-iconname="call"></ion-icon></ion-segment-button><ion-segment-buttonchecked><ion-iconname="heart"></ion-icon></ion-segment-button><ion-segment-button><ion-iconname="pin"></ion-icon></ion-segment-button></ion-segment><!-- Icon top --><ion-segment><ion-segment-button><ion-label>Item One</ion-label><ion-iconname="call"></ion-icon></ion-segment-button><ion-segment-buttonchecked><ion-label>Item Two</ion-label><ion-iconname="heart"></ion-icon></ion-segment-button><ion-segment-button><ion-label>Item Three</ion-label><ion-iconname="pin"></ion-icon></ion-segment-button></ion-segment><!-- Icon bottom --><ion-segment><ion-segment-buttoncheckedlayout="icon-bottom"><ion-iconname="call"></ion-icon><ion-label>Item One</ion-label></ion-segment-button><ion-segment-buttonlayout="icon-bottom"><ion-iconname="heart"></ion-icon><ion-label>Item Two</ion-label></ion-segment-button><ion-segment-buttonlayout="icon-bottom"><ion-iconname="pin"></ion-icon><ion-label>Item Three</ion-label></ion-segment-button></ion-segment><!-- Icon start --><ion-segment><ion-segment-buttoncheckedlayout="icon-start"><ion-label>Item One</ion-label><ion-iconname="call"></ion-icon></ion-segment-button><ion-segment-buttonlayout="icon-start"><ion-label>Item Two</ion-label><ion-iconname="heart"></ion-icon></ion-segment-button><ion-segment-buttonlayout="icon-start"><ion-label>Item Three</ion-label><ion-iconname="pin"></ion-icon></ion-segment-button></ion-segment><!-- Icon end --><ion-segment><ion-segment-buttoncheckedlayout="icon-end"><ion-iconname="call"></ion-icon><ion-label>Item One</ion-label></ion-segment-button><ion-segment-buttondisabledlayout="icon-end"><ion-iconname="heart"></ion-icon><ion-label>Item Two</ion-label></ion-segment-button><ion-segment-buttonlayout="icon-end"><ion-iconname="pin"></ion-icon><ion-label>Item Three</ion-label></ion-segment-button></ion-segment>
// Listen for ionClick on all segment buttonsconstsegmentButtons=document.querySelectorAll('ion-segment-button')for(leti=0;i<segmentButtons.length;i++){segmentButtons[i].addEventListener('ionSelect',(ev)=>{console.log('Segment button clicked',ev);})}
React
importReactfrom'react';import{IonSegment,IonSegmentButton,IonLabel,IonIcon,IonContent}from'@ionic/react';exportconstSegmentButtonExample: React.FC=()=>(<IonContent>{/*-- Segment buttons with text and click listeners --*/}<IonSegment><IonSegmentButtononIonSelect={()=>console.log('Friends segment selected')}><IonLabel>Friends</IonLabel></IonSegmentButton><IonSegmentButtononIonSelect={()=>console.log('Enemies segment selected')}><IonLabel>Enemies</IonLabel></IonSegmentButton></IonSegment>{/*-- Segment buttons with the first checked and the last disabled --*/}<IonSegment><IonSegmentButtonchecked><IonLabel>Paid</IonLabel></IonSegmentButton><IonSegmentButton><IonLabel>Free</IonLabel></IonSegmentButton><IonSegmentButtondisabled><IonLabel>Top</IonLabel></IonSegmentButton></IonSegment>{/*-- Segment buttons with values and icons --*/}<IonSegment><IonSegmentButtonvalue="camera"><IonIconname="camera"/></IonSegmentButton><IonSegmentButtonvalue="bookmark"><IonIconname="bookmark"/></IonSegmentButton></IonSegment>{/*-- Segment with a value that checks the last button --*/}<IonSegmentvalue="shared"><IonSegmentButtonvalue="bookmarks"><IonLabel>Bookmarks</IonLabel></IonSegmentButton><IonSegmentButtonvalue="reading"><IonLabel>Reading List</IonLabel></IonSegmentButton><IonSegmentButtonvalue="shared"><IonLabel>Shared Links</IonLabel></IonSegmentButton></IonSegment>{/*-- Label only --*/}<IonSegment><IonSegmentButtonchecked><IonLabel>Item One</IonLabel></IonSegmentButton><IonSegmentButton><IonLabel>Item Two</IonLabel></IonSegmentButton><IonSegmentButton><IonLabel>Item Three</IonLabel></IonSegmentButton></IonSegment>{/*-- Icon only --*/}<IonSegment><IonSegmentButton><IonIconname="call"/></IonSegmentButton><IonSegmentButtonchecked><IonIconname="heart"/></IonSegmentButton><IonSegmentButton><IonIconname="pin"/></IonSegmentButton></IonSegment>{/*-- Icon top --*/}<IonSegment><IonSegmentButton><IonLabel>Item One</IonLabel><IonIconname="call"/></IonSegmentButton><IonSegmentButtonchecked><IonLabel>Item Two</IonLabel><IonIconname="heart"/></IonSegmentButton><IonSegmentButton><IonLabel>Item Three</IonLabel><IonIconname="pin"/></IonSegmentButton></IonSegment>{/*-- Icon bottom --*/}<IonSegment><IonSegmentButtoncheckedlayout="icon-bottom"><IonIconname="call"/><IonLabel>Item One</IonLabel></IonSegmentButton><IonSegmentButtonlayout="icon-bottom"><IonIconname="heart"/><IonLabel>Item Two</IonLabel></IonSegmentButton><IonSegmentButtonlayout="icon-bottom"><IonIconname="pin"/><IonLabel>Item Three</IonLabel></IonSegmentButton></IonSegment>{/*-- Icon start --*/}<IonSegment><IonSegmentButtoncheckedlayout="icon-start"><IonLabel>Item One</IonLabel><IonIconname="call"/></IonSegmentButton><IonSegmentButtonlayout="icon-start"><IonLabel>Item Two</IonLabel><IonIconname="heart"/></IonSegmentButton><IonSegmentButtonlayout="icon-start"><IonLabel>Item Three</IonLabel><IonIconname="pin"/></IonSegmentButton></IonSegment>{/*-- Icon end --*/}<IonSegment><IonSegmentButtoncheckedlayout="icon-end"><IonIconname="call"/><IonLabel>Item One</IonLabel></IonSegmentButton><IonSegmentButtondisabledlayout="icon-end"><IonIconname="heart"/><IonLabel>Item Two</IonLabel></IonSegmentButton><IonSegmentButtonlayout="icon-end"><IonIconname="pin"/><IonLabel>Item Three</IonLabel></IonSegmentButton></IonSegment></IonContent>);
Vue
<template><!-- Segment buttons with text and click listeners --><ion-segment><ion-segment-button@ionSelect="segmentButtonClicked($event)"><ion-label>Friends</ion-label></ion-segment-button><ion-segment-button@ionSelect="segmentButtonClicked($event)"><ion-label>Enemies</ion-label></ion-segment-button></ion-segment><!-- Segment buttons with the first checked and the last disabled --><ion-segment><ion-segment-buttonchecked><ion-label>Paid</ion-label></ion-segment-button><ion-segment-button><ion-label>Free</ion-label></ion-segment-button><ion-segment-buttondisabled><ion-label>Top</ion-label></ion-segment-button></ion-segment><!-- Segment buttons with values and icons --><ion-segment><ion-segment-buttonvalue="camera"><ion-iconname="camera"></ion-icon></ion-segment-button><ion-segment-buttonvalue="bookmark"><ion-iconname="bookmark"></ion-icon></ion-segment-button></ion-segment><!-- Segment with a value that checks the last button --><ion-segmentvalue="shared"><ion-segment-buttonvalue="bookmarks"><ion-label>Bookmarks</ion-label></ion-segment-button><ion-segment-buttonvalue="reading"><ion-label>Reading List</ion-label></ion-segment-button><ion-segment-buttonvalue="shared"><ion-label>Shared Links</ion-label></ion-segment-button></ion-segment><!-- Label only --><ion-segment><ion-segment-buttonchecked><ion-label>Item One</ion-label></ion-segment-button><ion-segment-button><ion-label>Item Two</ion-label></ion-segment-button><ion-segment-button><ion-label>Item Three</ion-label></ion-segment-button></ion-segment><!-- Icon only --><ion-segment><ion-segment-button><ion-iconname="call"></ion-icon></ion-segment-button><ion-segment-buttonchecked><ion-iconname="heart"></ion-icon></ion-segment-button><ion-segment-button><ion-iconname="pin"></ion-icon></ion-segment-button></ion-segment><!-- Icon top --><ion-segment><ion-segment-button><ion-label>Item One</ion-label><ion-iconname="call"></ion-icon></ion-segment-button><ion-segment-buttonchecked><ion-label>Item Two</ion-label><ion-iconname="heart"></ion-icon></ion-segment-button><ion-segment-button><ion-label>Item Three</ion-label><ion-iconname="pin"></ion-icon></ion-segment-button></ion-segment><!-- Icon bottom --><ion-segment><ion-segment-buttoncheckedlayout="icon-bottom"><ion-iconname="call"></ion-icon><ion-label>Item One</ion-label></ion-segment-button><ion-segment-buttonlayout="icon-bottom"><ion-iconname="heart"></ion-icon><ion-label>Item Two</ion-label></ion-segment-button><ion-segment-buttonlayout="icon-bottom"><ion-iconname="pin"></ion-icon><ion-label>Item Three</ion-label></ion-segment-button></ion-segment><!-- Icon start --><ion-segment><ion-segment-buttoncheckedlayout="icon-start"><ion-label>Item One</ion-label><ion-iconname="call"></ion-icon></ion-segment-button><ion-segment-buttonlayout="icon-start"><ion-label>Item Two</ion-label><ion-iconname="heart"></ion-icon></ion-segment-button><ion-segment-buttonlayout="icon-start"><ion-label>Item Three</ion-label><ion-iconname="pin"></ion-icon></ion-segment-button></ion-segment><!-- Icon end --><ion-segment><ion-segment-buttoncheckedlayout="icon-end"><ion-iconname="call"></ion-icon><ion-label>Item One</ion-label></ion-segment-button><ion-segment-buttondisabledlayout="icon-end"><ion-iconname="heart"></ion-icon><ion-label>Item Two</ion-label></ion-segment-button><ion-segment-buttonlayout="icon-end"><ion-iconname="pin"></ion-icon><ion-label>Item Three</ion-label></ion-segment-button></ion-segment></template><scriptlang="ts">import{Component,Vue}from'vue-property-decorator';
@Component()exportdefaultclassExampleextendsVue{segmentButtonClicked(ev: any){console.log('Segment button clicked',ev);}}</script>
Properties
Property
Attribute
Description
Type
Default
checked
checked
If true, the segment button is selected.
boolean
false
disabled
disabled
If true, the user cannot interact with the segment button.
boolean
false
layout
layout
Set the layout of the text and icon in the segment.