Segment buttons are groups of related buttons inside of a segment . They are displayed in a horizontal row. A segment button can be selected by default by setting the value of the segment to the value of the segment button. Only one segment button can be selected at a time.
Basic Usage html src/app/example.component.html example.component.html ts src/app/example.component.ts example.component.ts
< ion-segment value = " buttons " >
< ion-segment-button value = " default " >
< ion-label > Default </ ion-label >
</ ion-segment-button >
< ion-segment-button value = " segment " >
< ion-label > Segment </ ion-label >
</ ion-segment-button >
< ion-segment-button value = " buttons " >
< ion-label > Button </ ion-label >
</ ion-segment-button >
</ ion-segment >
< ion-segment value = " buttons " >
< ion-segment-button value = " disabled " [disabled] = " true " >
< ion-label > Disabled </ ion-label >
</ ion-segment-button >
< ion-segment-button value = " segment " >
< ion-label > Segment </ ion-label >
</ ion-segment-button >
< ion-segment-button value = " buttons " >
< ion-label > Button </ ion-label >
</ ion-segment-button >
</ ion-segment > Layout The layout property is set to "icon-top" by default. When a segment button has both an icon and a label, it will display the icon on top of the label. This behavior can be changed by setting the layout property to "icon-bottom", "icon-start", or "icon-end" which will show the icon below the label, to the start of the label (left in LTR and right in RTL) or to the end of the label (right in LTR and left in RTL), respectively.
html src/app/example.component.html example.component.html ts src/app/example.component.ts example.component.ts
< ion-segment value = " heart " >
< ion-segment-button value = " call " >
< ion-icon name = " call " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " heart " >
< ion-icon name = " heart " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " pin " >
< ion-icon name = " pin " > </ ion-icon >
</ ion-segment-button >
</ ion-segment >
< ion-segment value = " heart " >
< ion-segment-button value = " call " >
< ion-label > Call </ ion-label >
< ion-icon name = " call " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " heart " >
< ion-label > Heart </ ion-label >
< ion-icon name = " heart " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " pin " >
< ion-label > Pin </ ion-label >
< ion-icon name = " pin " > </ ion-icon >
</ ion-segment-button >
</ ion-segment >
< ion-segment value = " heart " >
< ion-segment-button value = " call " layout = " icon-bottom " >
< ion-label > Call </ ion-label >
< ion-icon name = " call " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " heart " layout = " icon-bottom " >
< ion-label > Heart </ ion-label >
< ion-icon name = " heart " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " pin " layout = " icon-bottom " >
< ion-label > Pin </ ion-label >
< ion-icon name = " pin " > </ ion-icon >
</ ion-segment-button >
</ ion-segment >
< ion-segment value = " heart " >
< ion-segment-button value = " call " layout = " icon-start " >
< ion-label > Call </ ion-label >
< ion-icon name = " call " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " heart " layout = " icon-start " >
< ion-label > Heart </ ion-label >
< ion-icon name = " heart " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " pin " layout = " icon-start " >
< ion-label > Pin </ ion-label >
< ion-icon name = " pin " > </ ion-icon >
</ ion-segment-button >
</ ion-segment >
< ion-segment value = " heart " >
< ion-segment-button value = " call " layout = " icon-end " >
< ion-label > Call </ ion-label >
< ion-icon name = " call " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " heart " layout = " icon-end " >
< ion-label > Heart </ ion-label >
< ion-icon name = " heart " > </ ion-icon >
</ ion-segment-button >
< ion-segment-button value = " pin " layout = " icon-end " >
< ion-label > Pin </ ion-label >
< ion-icon name = " pin " > </ ion-icon >
</ ion-segment-button >
</ ion-segment > Theming CSS Shadow Parts html src/app/example.component.html example.component.html css src/app/example.component.css example.component.css ts src/app/example.component.ts example.component.ts
< ion-segment value = " custom " >
< ion-segment-button value = " custom " >
< ion-label > Custom </ ion-label >
</ ion-segment-button >
< ion-segment-button value = " segment " >
< ion-label > Segment </ ion-label >
</ ion-segment-button >
< ion-segment-button value = " buttons " >
< ion-label > Buttons </ ion-label >
</ ion-segment-button >
</ ion-segment > CSS Custom Properties html src/app/example.component.html example.component.html css src/app/example.component.css example.component.css ts src/app/example.component.ts example.component.ts
< ion-segment value = " custom " >
< ion-segment-button value = " custom " >
< ion-label > Custom </ ion-label >
</ ion-segment-button >
< ion-segment-button value = " segment " >
< ion-label > Segment </ ion-label >
</ ion-segment-button >
< ion-segment-button value = " buttons " >
< ion-label > Buttons </ ion-label >
</ ion-segment-button >
</ ion-segment > Properties contentId Description The id of the segment content. Attribute content-idType string | undefinedDefault undefined
disabled Description If true, the user cannot interact with the segment button. Attribute disabledType booleanDefault false
layout Description Set the layout of the text and icon in the segment. Attribute layoutType "icon-bottom" | "icon-end" | "icon-hide" | "icon-start" | "icon-top" | "label-hide" | undefinedDefault 'icon-top'
mode Description The mode determines which platform styles to use. This is a virtual property that is set once during initialization and will not update if you change its value after the initial render. Attribute modeType "ios" | "md"Default undefined
type Description The type of the button. Attribute typeType "button" | "reset" | "submit"Default 'button'
value Description The value of the segment button. Attribute valueType number | stringDefault 'ion-sb-' + ids++
Events No events available for this component.
Methods No public methods available for this component.
CSS Shadow Parts Name Description indicatorThe indicator displayed on the checked segment button. indicator-backgroundThe background element for the indicator displayed on the checked segment button. nativeThe native HTML button element that wraps all child elements.
CSS Custom Properties iOS MD
Name Description --backgroundBackground of the segment button --background-checkedBackground of the checked segment button --background-focusedBackground of the segment button when focused with the tab key --background-focused-opacityOpacity of the segment button background when focused with the tab key --background-hoverBackground of the segment button on hover --background-hover-opacityOpacity of the segment button background on hover --border-colorColor of the segment button border --border-radiusRadius of the segment button border --border-styleStyle of the segment button border --border-widthWidth of the segment button border --colorColor of the segment button --color-checkedColor of the checked segment button --color-focusedColor of the segment button when focused with the tab key --color-hoverColor of the segment button on hover --indicator-box-shadowBox shadow on the indicator for the checked segment button --indicator-colorColor of the indicator for the checked segment button --indicator-heightHeight of the indicator for the checked segment button --indicator-transformTransform of the indicator for the checked segment button --indicator-transitionTransition of the indicator for the checked segment button --margin-bottomBottom margin of the segment button --margin-endRight margin if direction is left-to-right, and left margin if direction is right-to-left of the segment button --margin-startLeft margin if direction is left-to-right, and right margin if direction is right-to-left of the segment button --margin-topTop margin of the segment button --padding-bottomBottom padding of the segment button --padding-endRight padding if direction is left-to-right, and left padding if direction is right-to-left of the segment button --padding-startLeft padding if direction is left-to-right, and right padding if direction is right-to-left of the segment button --padding-topTop padding of the segment button --transitionTransition of the segment button
Slots No slots available for this component.