ion-segment-button
セグメントボタンは、segmentの中にある、関連するボタンのグループです。それらは横一列に表示されます。セグメントの value
をセグメントボタンの value
に設定することで、デフォルトでセグメントボタンを選択することができます。一度に選択できるセグメントボタンは1つだけです。
基本的な使い方
<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
layout
プロパティは、デフォルトで "icon-top"
に設定されています。セグメントボタンにアイコンとラベルの両方がある場合、アイコンはラベルの上に表示されます。この動作は layout
プロパティを "icon-bottom"
, "icon-start"
, "icon-end"
に設定することで変更可能で、それぞれアイコンをラベルの下、ラベルの先頭(LTRでは左、RTLでは右)、ラベルの末尾(LTRでは右、RTLでは左)に表示することができます。
<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>
テーマ
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カスタムプロパティ
- 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;
}
プロパティ
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 | number | string |
Default | 'ion-sb-' + ids++ |
イベント
No events available for this component.
メソッド
No public methods available for this component.
CSS Shadow Parts
Name | Description |
---|---|
indicator | チェックしたセグメントボタンに表示されるインジケーターです。 |
indicator-background | チェックしたセグメントボタンに表示されるインジケータの背景要素です。 |
native | すべての子要素を包むネイティブ HTML ボタン要素。 |
CSSカスタムプロパティ
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.