ion-segment-button
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
<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.
<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
- src/app/example.component.css
- src/app/example.component.html
ion-segment-button::part(indicator-background) {
background: #08a391;
}
/* Material Design styles */
ion-segment-button.md::part(native) {
color: #000;
}
.segment-button-checked.md::part(native) {
color: #08a391;
}
ion-segment-button.md::part(indicator-background) {
height: 4px;
}
/* iOS styles */
ion-segment-button.ios::part(native) {
color: #08a391;
}
.segment-button-checked.ios::part(native) {
color: #fff;
}
ion-segment-button.ios::part(indicator-background) {
border-radius: 20px;
}
CSS Custom Properties
- src/app/example.component.css
- src/app/example.component.html
ion-segment-button {
--indicator-color: #08a391;
}
/* Material Design styles */
ion-segment-button.md {
--color: #000;
--color-checked: #08a391;
--indicator-height: 4px;
}
/* iOS styles */
ion-segment-button.ios {
--color: #08a391;
--color-checked: #fff;
--border-radius: 20px;
}
Properties
disabled
Description | true の場合、ユーザーはセグメントボタンを操作することができません。 |
Attribute | disabled |
Type | boolean |
Default | false |
layout
Description | セグメント内のテキストとアイコンのレイアウトを設定します。 |
Attribute | layout |
Type | "icon-bottom" | "icon-end" | "icon-hide" | "icon-start" | "icon-top" | "label-hide" | undefined |
Default | 'icon-top' |
mode
Description | modeは、どのプラットフォームのスタイルを使用するかを決定します。 |
Attribute | mode |
Type | "ios" | "md" |
Default | undefined |
type
Description | ボタンの種類です。 |
Attribute | type |
Type | "button" | "reset" | "submit" |
Default | 'button' |
value
Description | セグメントボタンの値です。 |
Attribute | value |
Type | string |
Default | 'ion-sb-' + ids++ |
Events
No events available for this component.
Methods
No public methods available for this component.
CSS Shadow Parts
Name | Description |
---|---|
indicator | チェックしたセグメントボタンに表示されるインジケーターです。 |
indicator-background | チェックしたセグメントボタンに表示されるインジケータの背景要素です。 |
native | すべての子要素を包むネイティブ HTML ボタン要素。 |
CSS Custom Properties
Name | Description |
---|---|
--background | セグメントボタンの背景 |
--background-checked | チェックしたセグメントボタンの背景 |
--background-focused | タブキーでフォーカスされたときのセグメントボタンの背景 |
--background-focused-opacity | タブキーでフォーカスしたときのセグメントボタンの背景の不透明度 |
--background-hover | セグメントボタンがホバーされたときの背景 |
--background-hover-opacity | ホバー時のセグメントボタンの背景の不透明度 |
--border-color | セグメントボタンのボーダーの色 |
--border-radius | セグメントボタンのボーダーの半径 |
--border-style | セグメントボタンのボーダーのスタイル |
--border-width | セグメントボタンの枠の幅 |
--color | セグメントボタンの色 |
--color-checked | チェックしたセグメントボタンの色 |
--color-focused | タブキーでフォーカスしたときのセグメントボタンの色 |
--color-hover | ホバー時のセグメントボタンの色 |
--indicator-box-shadow | チェックしたセグメントボタンのインジケーターにボックスシャドウを付ける |
--indicator-color | チェックしたセグメントボタンのインジケーターの色 |
--indicator-height | チェックしたセグメントボタンのインジケータの高さ |
--indicator-transform | チェックされたセグメントボタンのインジケータのトランスフォーム |
--indicator-transition | チェックしたセグメントボタンのインジケーターの遷移 |
--margin-bottom | セグメントボタンのBottom Margin |
--margin-end | セグメントボタンの方向が左から右の場合はRight Margin、右から左の場合はLeft Margin |
--margin-start | セグメントボタンの方向が左から右の場合はLeft Margin、右から左の場合はRight Margin |
--margin-top | セグメントボタンのTop Margin |
--padding-bottom | セグメントボタンのBottom Padding |
--padding-end | セグメントボタンの向きが左から右の場合はRight Padding、右から左の場合はLeft Paddingとなります。 |
--padding-start | セグメントボタンの向きが左から右の場合はLeft Padding、右から左の場合はRight Paddingとなります。 |
--padding-top | セグメントボタンのTop Padding |
--transition | セグメントボタンの遷移 |
Slots
No slots available for this component.