ion-segment-content
스와이프 가능한 세그먼트에서 화면을 담당하는 ion-segment-content 컴포넌트예요. 자식 요소의 표시를 제어하는 데 쓰이며, 하나의 segment view 안에 여러 개가 들어가 각각의 세그먼트 화면을 구성해요. 사용법은 swipeable segments 문서에서 자세히 확인할 수 있어요.
출처: 문서
본문
Encapsulation: shadow
Segment content는 스와이프 가능한 세그먼트를 사용할 때 자식 요소의 표시를 제어하는 래퍼 요소예요. Segment content 요소들은 하나의 segment view 인스턴스의 자식으로 들어가며, 이 인스턴스는 segment와 연결돼요. Segment content의 사용법에 대한 자세한 내용은 swipeable segments 문서를 참고해 주세요.
Usage
각 ion-segment-content에는 고유한 id 속성이 필요해요. 이 id는 segment button의 contentId 프로퍼티를 통해 segment content를 segment button에 연결하는 데 사용돼요.
JavaScript
<ion-segment>
<ion-segment-button value="first" content-id="first">
<ion-label>First</ion-label>
</ion-segment-button>
<ion-segment-button value="second" content-id="second">
<ion-label>Second</ion-label>
</ion-segment-button>
<ion-segment-button value="third" content-id="third">
<ion-label>Third</ion-label>
</ion-segment-button>
</ion-segment>
<ion-segment-view>
<ion-segment-content id="first">First</ion-segment-content>
<ion-segment-content id="second">Second</ion-segment-content>
<ion-segment-content id="third">Third</ion-segment-content>
</ion-segment-view>
<style>
ion-segment-view {
height: 150px;
}
ion-segment-content {
display: flex;
align-items: center;
justify-content: center;
}
ion-segment-content:nth-of-type(1) {
background: lightpink;
}
ion-segment-content:nth-of-type(2) {
background: lightblue;
}
ion-segment-content:nth-of-type(3) {
background: lightgreen;
}
</style>
Angular
src/app/example.component.html
<ion-segment>
<ion-segment-button value="first" content-id="first">
<ion-label>First</ion-label>
</ion-segment-button>
<ion-segment-button value="second" content-id="second">
<ion-label>Second</ion-label>
</ion-segment-button>
<ion-segment-button value="third" content-id="third">
<ion-label>Third</ion-label>
</ion-segment-button>
</ion-segment>
<ion-segment-view>
<ion-segment-content id="first">First</ion-segment-content>
<ion-segment-content id="second">Second</ion-segment-content>
<ion-segment-content id="third">Third</ion-segment-content>
</ion-segment-view>
src/app/example.component.css
ion-segment-view {
height: 150px;
}
ion-segment-content {
display: flex;
align-items: center;
justify-content: center;
}
ion-segment-content:nth-of-type(1) {
background: lightpink;
}
ion-segment-content:nth-of-type(2) {
background: lightblue;
}
ion-segment-content:nth-of-type(3) {
background: lightgreen;
}
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonLabel, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonLabel, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView],
})
export class ExampleComponent {}
React
src/main.css
ion-segment-view {
height: 150px;
}
ion-segment-content {
display: flex;
align-items: center;
justify-content: center;
}
ion-segment-content:nth-of-type(1) {
background: lightpink;
}
ion-segment-content:nth-of-type(2) {
background: lightblue;
}
ion-segment-content:nth-of-type(3) {
background: lightgreen;
}
src/main.tsx
import React from 'react';
import { IonLabel, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView } from '@ionic/react';
import './main.css';
function Example() {
return (
<>
<IonSegment value="first">
<IonSegmentButton value="first" contentId="first">
<IonLabel>First</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="second" contentId="second">
<IonLabel>Second</IonLabel>
</IonSegmentButton>
<IonSegmentButton value="third" contentId="third">
<IonLabel>Third</IonLabel>
</IonSegmentButton>
</IonSegment>
<IonSegmentView>
<IonSegmentContent id="first">First</IonSegmentContent>
<IonSegmentContent id="second">Second</IonSegmentContent>
<IonSegmentContent id="third">Third</IonSegmentContent>
</IonSegmentView>
</>
);
}
export default Example;
Vue
<template>
<ion-segment>
<ion-segment-button value="first" content-id="first">
<ion-label>First</ion-label>
</ion-segment-button>
<ion-segment-button value="second" content-id="second">
<ion-label>Second</ion-label>
</ion-segment-button>
<ion-segment-button value="third" content-id="third">
<ion-label>Third</ion-label>
</ion-segment-button>
</ion-segment>
<ion-segment-view>
<ion-segment-content id="first">First</ion-segment-content>
<ion-segment-content id="second">Second</ion-segment-content>
<ion-segment-content id="third">Third</ion-segment-content>
</ion-segment-view>
</template>
<style>
ion-segment-view {
height: 150px;
}
ion-segment-content {
display: flex;
align-items: center;
justify-content: center;
}
ion-segment-content:nth-of-type(1) {
background: lightpink;
}
ion-segment-content:nth-of-type(2) {
background: lightblue;
}
ion-segment-content:nth-of-type(3) {
background: lightgreen;
}
</style>
<script setup lang="ts">
import { IonLabel, IonSegment, IonSegmentButton, IonSegmentContent, IonSegmentView } from '@ionic/vue';
</script>
Properties
이 컴포넌트에는 사용할 수 있는 프로퍼티가 없어요.
Events
이 컴포넌트에는 사용할 수 있는 이벤트가 없어요.
Methods
이 컴포넌트에는 공개된 메서드가 없어요.
CSS Shadow Parts
이 컴포넌트에는 사용할 수 있는 CSS shadow part가 없어요.
CSS Custom Properties
이 컴포넌트에는 사용할 수 있는 CSS 커스텀 프로퍼티가 없어요.
Slots
| Name | Description |
|---|---|
| 기본 슬롯이에요. |
더 알아보기 (Learn more)
segment content를 쓸 때는 반드시 각각 고유한 id를 부여하고, segment button의 content-id로 연결해 주어야 해요. 이렇게 연결해야 스와이프할 때 올바른 화면으로 전환돼요. 궁금한 점이 있다면 segment 문서도 함께 확인해 보세요.