ion-segment-button
segment 안에 들어가는 버튼 그룹의 한 요소인 ion-segment-button이에요. 가로로 나란히 배치되며, segment의 value를 특정 segment button의 value와 맞추면 그 버튼이 기본 선택 상태가 돼요. 한 번에 하나의 segment button만 선택할 수 있어요.
출처: 문서
본문
Encapsulation: shadow
Segment button은 segment 안에 들어가는 서로 관련된 버튼들의 그룹이에요. 가로로 한 줄에 표시되며, segment의 value를 segment button의 value로 설정하면 해당 버튼이 기본 선택 상태가 돼요. 한 번에 하나의 segment button만 선택할 수 있어요.
Basic Usage
JavaScript
<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>
Angular
src/app/example.component.html
<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>
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonLabel, IonSegment, IonSegmentButton } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonLabel, IonSegment, IonSegmentButton],
})
export class ExampleComponent {}
React
import React from 'react';
import { IonLabel, IonSegment, IonSegmentButton } from '@ionic/react';
function Example() {
return (
<>
<IonSegment value="buttons">
<IonSegmentButton value="default">
<IonLabel>Default</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="segment">
<IonLabel>Segment</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="buttons">
<IonLabel>Button</IonLabel>
</IonSegmentButton>
</IonSegment>
<IonSegment value="buttons">
<IonSegmentButton value="disabled" disabled={true}>
<IonLabel>Disabled</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="segment">
<IonLabel>Segment</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="buttons">
<IonLabel>Button</IonLabel>
</IonSegmentButton>
</IonSegment>
</>
);
}
export default Example;
Vue
<template>
<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>
</template>
<script setup lang="ts">
import { IonLabel, IonSegment, IonSegmentButton } from '@ionic/vue';
</script>
Layout
layout 프로퍼티는 기본값이 "icon-top"이에요. segment button에 아이콘과 라벨이 모두 있으면 아이콘이 라벨 위에 표시돼요. 이 동작은 layout 프로퍼티를 "icon-bottom", "icon-start", "icon-end"로 바꿔서 조정할 수 있어요. 각각 아이콘을 라벨 아래, 라벨의 시작 쪽(LTR에서는 왼쪽, RTL에서는 오른쪽), 라벨의 끝 쪽(LTR에서는 오른쪽, RTL에서는 왼쪽)에 표시해 줘요.
JavaScript
index.html
<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>
index.ts
import { defineCustomElements } from '@ionic/core/loader';
import { addIcons } from 'ionicons';
import { call, heart, pin } from 'ionicons/icons';
/* Core CSS required for Ionic components to work properly */
import '@ionic/core/css/core.css';
/* Basic CSS for apps built with Ionic */
import '@ionic/core/css/normalize.css';
import '@ionic/core/css/structure.css';
import '@ionic/core/css/typography.css';
/* Optional CSS utils that can be commented out */
import '@ionic/core/css/padding.css';
import '@ionic/core/css/float-elements.css';
import '@ionic/core/css/text-alignment.css';
import '@ionic/core/css/text-transformation.css';
import '@ionic/core/css/flex-utils.css';
import '@ionic/core/css/display.css';
/**
* Ionic Dark Palette
* -----------------------------------------------------
* For more information, please see:
* https://ionicframework.com/docs/theming/dark-mode
*/
// import '@ionic/core/css/palettes/dark.always.css';
// import '@ionic/core/css/palettes/dark.class.css';
import '@ionic/core/css/palettes/dark.system.css';
/* Theme variables */
import './theme/variables.css';
/**
* On Ionicons 7.2+ these icons
* get mapped to a kebab-case key.
* Alternatively, developers can do:
* addIcons({ 'call': call, 'heart': heart, 'pin': pin });
*/
addIcons({ call, heart, pin });
defineCustomElements();
Angular
src/app/example.component.html
<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>
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonIcon, IonLabel, IonSegment, IonSegmentButton } from '@ionic/angular';
import { addIcons } from 'ionicons';
import { call, heart, pin } from 'ionicons/icons';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonIcon, IonLabel, IonSegment, IonSegmentButton],
})
export class ExampleComponent {
constructor() {
/**
* Any icons you want to use in your application
* can be registered in app.component.ts and then
* referenced by name anywhere in your application.
*/
addIcons({ call, heart, pin });
}
}
React
import React from 'react';
import { IonIcon, IonLabel, IonSegment, IonSegmentButton } from '@ionic/react';
import { call, heart, pin } from 'ionicons/icons';
function Example() {
return (
<>
<IonSegment value="heart">
<IonSegmentButton value="call">
<IonIcon icon={call}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="heart">
<IonIcon icon={heart}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="pin">
<IonIcon icon={pin}></IonIcon>
</IonSegmentButton>
</IonSegment>
<IonSegment value="heart">
<IonSegmentButton value="call">
<IonLabel>Call</IonLabel>
<IonIcon icon={call}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="heart">
<IonLabel>Heart</IonLabel>
<IonIcon icon={heart}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="pin">
<IonLabel>Pin</IonLabel>
<IonIcon icon={pin}></IonIcon>
</IonSegmentButton>
</IonSegment>
<IonSegment value="heart">
<IonSegmentButton value="call" layout="icon-bottom">
<IonLabel>Call</IonLabel>
<IonIcon icon={call}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="heart" layout="icon-bottom">
<IonLabel>Heart</IonLabel>
<IonIcon icon={heart}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="pin" layout="icon-bottom">
<IonLabel>Pin</IonLabel>
<IonIcon icon={pin}></IonIcon>
</IonSegmentButton>
</IonSegment>
<IonSegment value="heart">
<IonSegmentButton value="call" layout="icon-start">
<IonLabel>Call</IonLabel>
<IonIcon icon={call}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="heart" layout="icon-start">
<IonLabel>Heart</IonLabel>
<IonIcon icon={heart}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="pin" layout="icon-start">
<IonLabel>Pin</IonLabel>
<IonIcon icon={pin}></IonIcon>
</IonSegmentButton>
</IonSegment>
<IonSegment value="heart">
<IonSegmentButton value="call" layout="icon-end">
<IonLabel>Call</IonLabel>
<IonIcon icon={call}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="heart" layout="icon-end">
<IonLabel>Heart</IonLabel>
<IonIcon icon={heart}></IonIcon>
</IonSegmentButton>
<IonSegmentButton value="pin" layout="icon-end">
<IonLabel>Pin</IonLabel>
<IonIcon icon={pin}></IonIcon>
</IonSegmentButton>
</IonSegment>
</>
);
}
export default Example;
Vue
<template>
<ion-segment value="heart">
<ion-segment-button value="call">
<ion-icon :icon="call"></ion-icon>
</ion-segment-button>
<ion-segment-button value="heart">
<ion-icon :icon="heart"></ion-icon>
</ion-segment-button>
<ion-segment-button value="pin">
<ion-icon :icon="pin"></ion-icon>
</ion-segment-button>
</ion-segment>
<ion-segment value="heart">
<ion-segment-button value="call">
<ion-label>Call</ion-label>
<ion-icon :icon="call"></ion-icon>
</ion-segment-button>
<ion-segment-button value="heart">
<ion-label>Heart</ion-label>
<ion-icon :icon="heart"></ion-icon>
</ion-segment-button>
<ion-segment-button value="pin">
<ion-label>Pin</ion-label>
<ion-icon :icon="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 :icon="call"></ion-icon>
</ion-segment-button>
<ion-segment-button value="heart" layout="icon-bottom">
<ion-label>Heart</ion-label>
<ion-icon :icon="heart"></ion-icon>
</ion-segment-button>
<ion-segment-button value="pin" layout="icon-bottom">
<ion-label>Pin</ion-label>
<ion-icon :icon="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 :icon="call"></ion-icon>
</ion-segment-button>
<ion-segment-button value="heart" layout="icon-start">
<ion-label>Heart</ion-label>
<ion-icon :icon="heart"></ion-icon>
</ion-segment-button>
<ion-segment-button value="pin" layout="icon-start">
<ion-label>Pin</ion-label>
<ion-icon :icon="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 :icon="call"></ion-icon>
</ion-segment-button>
<ion-segment-button value="heart" layout="icon-end">
<ion-label>Heart</ion-label>
<ion-icon :icon="heart"></ion-icon>
</ion-segment-button>
<ion-segment-button value="pin" layout="icon-end">
<ion-label>Pin</ion-label>
<ion-icon :icon="pin"></ion-icon>
</ion-segment-button>
</ion-segment>
</template>
<script setup lang="ts">
import { IonIcon, IonLabel, IonSegment, IonSegmentButton } from '@ionic/vue';
import { call, heart, pin } from 'ionicons/icons';
</script>
Theming
CSS Shadow Parts
JavaScript
<style>
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;
}
</style>
<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>
Angular
src/app/example.component.html
<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>
src/app/example.component.css
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;
}
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonLabel, IonSegment, IonSegmentButton } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonLabel, IonSegment, IonSegmentButton],
})
export class ExampleComponent {}
React
src/main.css
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;
}
src/main.tsx
import React from 'react';
import { IonLabel, IonSegment, IonSegmentButton } from '@ionic/react';
import './main.css';
function Example() {
return (
<IonSegment value="custom">
<IonSegmentButton value="custom">
<IonLabel>Custom</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="segment">
<IonLabel>Segment</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="buttons">
<IonLabel>Buttons</IonLabel>
</IonSegmentButton>
</IonSegment>
);
}
export default Example;
Vue
<template>
<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>
</template>
<script setup lang="ts">
import { IonLabel, IonSegment, IonSegmentButton } from '@ionic/vue';
</script>
<style>
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;
}
</style>
CSS Custom Properties
JavaScript
<style>
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;
}
</style>
<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>
Angular
src/app/example.component.html
<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>
src/app/example.component.css
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;
}
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonLabel, IonSegment, IonSegmentButton } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonLabel, IonSegment, IonSegmentButton],
})
export class ExampleComponent {}
React
src/main.css
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;
}
src/main.tsx
import React from 'react';
import { IonLabel, IonSegment, IonSegmentButton } from '@ionic/react';
import './main.css';
function Example() {
return (
<IonSegment value="custom">
<IonSegmentButton value="custom">
<IonLabel>Custom</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="segment">
<IonLabel>Segment</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="buttons">
<IonLabel>Buttons</IonLabel>
</IonSegmentButton>
</IonSegment>
);
}
export default Example;
Vue
<template>
<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>
</template>
<script setup lang="ts">
import { IonLabel, IonSegment, IonSegmentButton } from '@ionic/vue';
</script>
<style>
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;
}
</style>
Properties
contentId
Description: segment content의 id예요.
Attribute: content-id
Type: string | undefined
Default: undefined
disabled
Description: true로 설정하면 사용자가 segment button과 상호작용할 수 없어요.
Attribute: disabled
Type: boolean
Default: false
layout
Description: segment 안 텍스트와 아이콘의 배치를 설정해요.
Attribute: layout
Type: "icon-bottom" | "icon-end" | "icon-hide" | "icon-start" | "icon-top" | "label-hide" | undefined
Default: 'icon-top'
mode
Description: mode는 어떤 플랫폼 스타일을 사용할지 결정해요. 이 값은 초기화할 때 한 번 설정되는 virtual property라서, 첫 렌더링 이후에 값을 바꿔도 업데이트되지 않아요.
Attribute: mode
Type: "ios" | "md"
Default: undefined
type
Description: 버튼의 타입이에요.
Attribute: type
Type: "button" | "reset" | "submit"
Default: 'button'
value
Description: segment button의 값이에요.
Attribute: value
Type: number | string
Default: 'ion-sb-' + ids++
Events
이 컴포넌트에는 사용할 수 있는 이벤트가 없어요.
Methods
이 컴포넌트에는 공개된 메서드가 없어요.
CSS Shadow Parts
| Name | Description |
|---|---|
indicator |
선택된 segment button에 표시되는 인디케이터예요. |
indicator-background |
선택된 segment button에 표시되는 인디케이터의 배경 요소예요. |
native |
모든 자식 요소를 감싸는 기본 HTML button 요소예요. |
CSS Custom Properties
iOS
| Name | Description |
|---|---|
--background |
segment button의 배경색 |
--background-checked |
선택된 segment button의 배경색 |
--background-focused |
Tab 키로 포커스됐을 때 segment button의 배경색 |
--background-focused-opacity |
Tab 키로 포커스됐을 때 segment button 배경의 불투명도 |
--background-hover |
마우스를 올렸을 때 segment button의 배경색 |
--background-hover-opacity |
마우스를 올렸을 때 segment button 배경의 불투명도 |
--border-color |
segment button 테두리의 색상 |
--border-radius |
segment button 테두리의 둥근 정도 |
--border-style |
segment button 테두리의 스타일 |
--border-width |
segment button 테두리의 두께 |
--color |
segment button의 색상 |
--color-checked |
선택된 segment button의 색상 |
--color-focused |
Tab 키로 포커스됐을 때 segment button의 색상 |
--color-hover |
마우스를 올렸을 때 segment button의 색상 |
--indicator-box-shadow |
선택된 segment button의 인디케이터에 적용되는 박스 그림자 |
--indicator-color |
선택된 segment button의 인디케이터 색상 |
--indicator-height |
선택된 segment button의 인디케이터 높이 |
--indicator-transform |
선택된 segment button의 인디케이터 변환 |
--indicator-transition |
선택된 segment button의 인디케이터 전환 |
--margin-bottom |
segment button의 아래쪽 바깥 여백 |
--margin-end |
왼쪽에서 오른쪽 방향이면 오른쪽, 오른쪽에서 왼쪽 방향이면 왼쪽의 바깥 여백 |
--margin-start |
왼쪽에서 오른쪽 방향이면 왼쪽, 오른쪽에서 왼쪽 방향이면 오른쪽의 바깥 여백 |
--margin-top |
segment button의 위쪽 바깥 여백 |
--padding-bottom |
segment button의 아래쪽 안쪽 여백 |
--padding-end |
왼쪽에서 오른쪽 방향이면 오른쪽, 오른쪽에서 왼쪽 방향이면 왼쪽의 안쪽 여백 |
--padding-start |
왼쪽에서 오른쪽 방향이면 왼쪽, 오른쪽에서 왼쪽 방향이면 오른쪽의 안쪽 여백 |
--padding-top |
segment button의 위쪽 안쪽 여백 |
--transition |
segment button의 전환 효과 |
MD
| Name | Description |
|---|---|
--background |
segment button의 배경색 |
--background-checked |
선택된 segment button의 배경색 |
--background-focused |
Tab 키로 포커스됐을 때 segment button의 배경색 |
--background-focused-opacity |
Tab 키로 포커스됐을 때 segment button 배경의 불투명도 |
--background-hover |
마우스를 올렸을 때 segment button의 배경색 |
--background-hover-opacity |
마우스를 올렸을 때 segment button 배경의 불투명도 |
--border-color |
segment button 테두리의 색상 |
--border-radius |
segment button 테두리의 둥근 정도 |
--border-style |
segment button 테두리의 스타일 |
--border-width |
segment button 테두리의 두께 |
--color |
segment button의 색상 |
--color-checked |
선택된 segment button의 색상 |
--color-focused |
Tab 키로 포커스됐을 때 segment button의 색상 |
--color-hover |
마우스를 올렸을 때 segment button의 색상 |
--indicator-box-shadow |
선택된 segment button의 인디케이터에 적용되는 박스 그림자 |
--indicator-color |
선택된 segment button의 인디케이터 색상 |
--indicator-height |
선택된 segment button의 인디케이터 높이 |
--indicator-transform |
선택된 segment button의 인디케이터 변환 |
--indicator-transition |
선택된 segment button의 인디케이터 전환 |
--margin-bottom |
segment button의 아래쪽 바깥 여백 |
--margin-end |
왼쪽에서 오른쪽 방향이면 오른쪽, 오른쪽에서 왼쪽 방향이면 왼쪽의 바깥 여백 |
--margin-start |
왼쪽에서 오른쪽 방향이면 왼쪽, 오른쪽에서 왼쪽 방향이면 오른쪽의 바깥 여백 |
--margin-top |
segment button의 위쪽 바깥 여백 |
--padding-bottom |
segment button의 아래쪽 안쪽 여백 |
--padding-end |
왼쪽에서 오른쪽 방향이면 오른쪽, 오른쪽에서 왼쪽 방향이면 왼쪽의 안쪽 여백 |
--padding-start |
왼쪽에서 오른쪽 방향이면 왼쪽, 오른쪽에서 왼쪽 방향이면 오른쪽의 안쪽 여백 |
--padding-top |
segment button의 위쪽 안쪽 여백 |
--transition |
segment button의 전환 효과 |
Slots
| Name | Description |
|---|---|
| 기본 슬롯이에요. |
더 알아보기 (Learn more)
segment button은 라벨과 아이콘의 배치를 layout 프로퍼티로 유연하게 조절할 수 있어요. 스타일을 입힐 때는 ::part()와 CSS 커스텀 프로퍼티를 활용하면 편리해요. 다음으로 segment 문서를 함께 보시면 전체 구조를 이해하는 데 도움이 돼요.