진행 표시줄 (ion-progress-bar)
진행 표시줄(Progress Bar)은 앱 로딩, 폼 제출, 업데이트 저장 같은 진행 중인 프로세스의 상태를 사용자에게 알려주는 컴포넌트예요. determinate와 indeterminate 두 가지 타입이 있습니다.
출처: 문서
본문
진행 표시줄은 앱 로딩, 폼 제출, 업데이트 저장 같은 진행 중인 프로세스의 상태를 사용자에게 알려줍니다. 두 가지 타입이 있습니다: determinate와 indeterminate.
Determinate
Determinate는 기본 타입입니다. 작업의 진행률(백분율)을 알 때 사용해야 해요. 진행 상태는 value 프로퍼티를 설정해 나타냅니다. 이 값으로 트랙의 0%에서 100%까지 진행이 늘어나는 모습을 보여줄 수 있습니다.
JavaScript
<ion-progress-bar></ion-progress-bar>
<script>
let progress = 0;
let progressBar = document.querySelector('ion-progress-bar');
setInterval(() => {
progressBar.value = progress += 0.01;
// Reset the progress bar when it reaches 100%
// to continuously show the demo
if (progress > 1) {
setTimeout(() => {
progressBar.value = progress = 0;
}, 1000);
}
}, 50);
</script>
Angular
src/app/example.component.html
<ion-progress-bar [value]="progress()"></ion-progress-bar>
src/app/example.component.ts
import { Component, signal } from '@angular/core';
import { IonProgressBar } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonProgressBar],
})
export class ExampleComponent {
readonly progress = signal(0);
constructor() {
setInterval(() => {
this.progress.update((value) => value + 0.01);
// Reset the progress bar when it reaches 100%
// to continuously show the demo
if (this.progress() > 1) {
setTimeout(() => {
this.progress.set(0);
}, 1000);
}
}, 50);
}
}
React
import React, { useEffect, useState } from 'react';
import { IonProgressBar } from '@ionic/react';
function Example() {
const [progress, setProgress] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setProgress((prevProgress) => prevProgress + 0.01);
}, 50);
return () => clearInterval(interval);
}, []);
if (progress > 1) {
setTimeout(() => {
setProgress(0);
}, 1000);
}
return <IonProgressBar value={progress}></IonProgressBar>;
}
export default Example;
Vue
<template>
<ion-progress-bar :value="progress"></ion-progress-bar>
</template>
<script setup lang="ts">
import { IonProgressBar } from '@ionic/vue';
import { ref, onMounted } from 'vue';
const progress = ref(0);
onMounted(() => {
setInterval(() => {
progress.value += 0.01;
// Reset the progress bar when it reaches 100%
// to continuously show the demo
if (progress.value > 1) {
setTimeout(() => {
progress.value = 0;
}, 1000);
}
}, 50);
});
</script>
버퍼 (Buffer)
buffer 프로퍼티가 설정되면, 활동 중임을 나타내는 애니메이션 원이 있는 버퍼 스트림이 표시됩니다. buffer 프로퍼티의 값은 보이는 트랙의 양으로도 나타나요. buffer의 값이 value 프로퍼티보다 작으면 보이는 트랙이 없습니다. buffer가 1과 같으면 버퍼 스트림이 숨겨집니다.
JavaScript
<ion-progress-bar></ion-progress-bar>
<script>
let buffer = 0.06;
let progress = 0;
let progressBar = document.querySelector('ion-progress-bar');
progressBar.buffer = buffer;
setInterval(() => {
progressBar.buffer = buffer += 0.06;
progressBar.value = progress += 0.06;
// Reset the progress bar when it reaches 100%
// to continuously show the demo
if (progress > 1) {
setTimeout(() => {
progressBar.buffer = buffer = 0.06;
progressBar.value = progress = 0;
}, 1000);
}
}, 1000);
</script>
Angular
src/app/example.component.html
<ion-progress-bar [buffer]="buffer()" [value]="progress()"></ion-progress-bar>
src/app/example.component.ts
import { Component, signal } from '@angular/core';
import { IonProgressBar } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonProgressBar],
})
export class ExampleComponent {
readonly buffer = signal(0.06);
readonly progress = signal(0);
constructor() {
setInterval(() => {
this.buffer.update((value) => value + 0.06);
this.progress.update((value) => value + 0.06);
// Reset the progress bar when it reaches 100%
// to continuously show the demo
if (this.progress() > 1) {
setTimeout(() => {
this.buffer.set(0.06);
this.progress.set(0);
}, 1000);
}
}, 1000);
}
}
React
import React, { useEffect, useState } from 'react';
import { IonProgressBar } from '@ionic/react';
function Example() {
const [buffer, setBuffer] = useState(0.06);
const [progress, setProgress] = useState(0);
useEffect(() => {
const interval = setInterval(() => {
setBuffer((prevBuffer) => prevBuffer + 0.06);
setProgress((prevProgress) => prevProgress + 0.06);
}, 1000);
return () => clearInterval(interval);
}, []);
if (progress > 1) {
setTimeout(() => {
setBuffer(0.06);
setProgress(0);
}, 1000);
}
return <IonProgressBar buffer={buffer} value={progress}></IonProgressBar>;
}
export default Example;
Vue
<template>
<ion-progress-bar :buffer="buffer" :value="progress"></ion-progress-bar>
</template>
<script setup lang="ts">
import { IonProgressBar } from '@ionic/vue';
import { ref, onMounted } from 'vue';
const buffer = ref(0.06);
const progress = ref(0);
onMounted(() => {
setInterval(() => {
buffer.value += 0.06;
progress.value += 0.06;
// Reset the progress bar when it reaches 100%
// to continuously show the demo
if (progress.value > 1) {
setTimeout(() => {
buffer.value = 0.06;
progress.value = 0;
}, 1000);
}
}, 1000);
});
</script>
Indeterminate
Indeterminate 타입은 프로세스가 얼마나 걸릴지 알 수 없을 때 사용해야 해요. 진행 표시줄은 value와 연결되지 않고, 프로세스가 끝날 때까지 트랙을 따라 계속 좌우로 움직입니다.
JavaScript
<ion-progress-bar type="indeterminate"></ion-progress-bar>
Angular
src/app/example.component.html
<ion-progress-bar type="indeterminate"></ion-progress-bar>
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonProgressBar } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonProgressBar],
})
export class ExampleComponent {}
React
import React from 'react';
import { IonProgressBar } from '@ionic/react';
function Example() {
return <IonProgressBar type="indeterminate"></IonProgressBar>;
}
export default Example;
Vue
<template>
<ion-progress-bar type="indeterminate"></ion-progress-bar>
</template>
<script setup lang="ts">
import { IonProgressBar } from '@ionic/vue';
</script>
툴바 안의 진행 표시줄 (Progress Bars in Toolbars)
JavaScript
<ion-header>
<ion-toolbar>
<ion-title>Toolbar</ion-title>
<ion-progress-bar type="indeterminate"></ion-progress-bar>
</ion-toolbar>
</ion-header>
Angular
src/app/example.component.html
<ion-header>
<ion-toolbar>
<ion-title>Toolbar</ion-title>
<ion-progress-bar type="indeterminate"></ion-progress-bar>
</ion-toolbar>
</ion-header>
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonHeader, IonProgressBar, IonTitle, IonToolbar } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonHeader, IonProgressBar, IonTitle, IonToolbar],
})
export class ExampleComponent {}
React
import React from 'react';
import { IonHeader, IonProgressBar, IonTitle, IonToolbar } from '@ionic/react';
function Example() {
return (
<IonHeader>
<IonToolbar>
<IonTitle>Toolbar</IonTitle>
<IonProgressBar type="indeterminate"></IonProgressBar>
</IonToolbar>
</IonHeader>
);
}
export default Example;
Vue
<template>
<ion-header>
<ion-toolbar>
<ion-title>Toolbar</ion-title>
<ion-progress-bar type="indeterminate"></ion-progress-bar>
</ion-toolbar>
</ion-header>
</template>
<script setup lang="ts">
import { IonHeader, IonProgressBar, IonTitle, IonToolbar } from '@ionic/vue';
</script>
테마 적용 (Theming)
색상 (Colors)
JavaScript
<ion-progress-bar type="indeterminate" color="primary"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="secondary"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="tertiary"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="success"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="warning"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="danger"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="light"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="medium"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="dark"></ion-progress-bar>
Angular
src/app/example.component.html
<ion-progress-bar type="indeterminate" color="primary"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="secondary"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="tertiary"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="success"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="warning"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="danger"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="light"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="medium"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="dark"></ion-progress-bar>
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonProgressBar } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonProgressBar],
})
export class ExampleComponent {}
React
import React from 'react';
import { IonProgressBar } from '@ionic/react';
function Example() {
return (
<>
<IonProgressBar type="indeterminate" color="primary"></IonProgressBar>
<IonProgressBar type="indeterminate" color="secondary"></IonProgressBar>
<IonProgressBar type="indeterminate" color="tertiary"></IonProgressBar>
<IonProgressBar type="indeterminate" color="success"></IonProgressBar>
<IonProgressBar type="indeterminate" color="warning"></IonProgressBar>
<IonProgressBar type="indeterminate" color="danger"></IonProgressBar>
<IonProgressBar type="indeterminate" color="light"></IonProgressBar>
<IonProgressBar type="indeterminate" color="medium"></IonProgressBar>
<IonProgressBar type="indeterminate" color="dark"></IonProgressBar>
</>
);
}
export default Example;
Vue
<template>
<ion-progress-bar type="indeterminate" color="primary"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="secondary"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="tertiary"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="success"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="warning"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="danger"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="light"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="medium"></ion-progress-bar>
<ion-progress-bar type="indeterminate" color="dark"></ion-progress-bar>
</template>
<script setup lang="ts">
import { IonProgressBar } from '@ionic/vue';
</script>
CSS Custom Properties
JavaScript
<style>
ion-progress-bar {
--background: #f3e895;
--progress-background: #09c567;
}
</style>
<ion-progress-bar value=".25" buffer=".5"></ion-progress-bar>
<ion-progress-bar type="indeterminate"></ion-progress-bar>
Angular
src/app/example.component.html
<ion-progress-bar value=".25" buffer=".5"></ion-progress-bar> <ion-progress-bar type="indeterminate"></ion-progress-bar>
src/app/example.component.css
ion-progress-bar {
--background: #f3e895;
--progress-background: #09c567;
}
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonProgressBar } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonProgressBar],
})
export class ExampleComponent {}
React
src/main.tsx
import React from 'react';
import { IonProgressBar } from '@ionic/react';
import './main.css';
function Example() {
return (
<>
<IonProgressBar value={0.25} buffer={0.5}></IonProgressBar>
<IonProgressBar type="indeterminate"></IonProgressBar>
</>
);
}
export default Example;
src/main.css
ion-progress-bar {
--background: #f3e895;
--progress-background: #09c567;
}
Vue
<template>
<ion-progress-bar :value=".25" :buffer=".5"></ion-progress-bar>
<ion-progress-bar type="indeterminate"></ion-progress-bar>
</template>
<script setup lang="ts">
import { IonProgressBar } from '@ionic/vue';
</script>
<style scoped>
ion-progress-bar {
--background: #f3e895;
--progress-background: #09c567;
}
</style>
CSS Shadow Parts
JavaScript
<style>
ion-progress-bar::part(track) {
background: #f3e895;
}
ion-progress-bar::part(progress) {
background: #09c567;
}
ion-progress-bar::part(stream) {
background-image: radial-gradient(ellipse at center, #e475f3 0%, #e475f3 30%, transparent 30%);
}
</style>
<ion-progress-bar value=".25" buffer=".5"></ion-progress-bar>
<ion-progress-bar type="indeterminate"></ion-progress-bar>
Angular
src/app/example.component.html
<ion-progress-bar value=".25" buffer=".5"></ion-progress-bar> <ion-progress-bar type="indeterminate"></ion-progress-bar>
src/app/example.component.css
ion-progress-bar::part(track) {
background: #f3e895;
}
ion-progress-bar::part(progress) {
background: #09c567;
}
ion-progress-bar::part(stream) {
background-image: radial-gradient(ellipse at center, #e475f3 0%, #e475f3 30%, transparent 30%);
}
src/app/example.component.ts
import { Component } from '@angular/core';
import { IonProgressBar } from '@ionic/angular';
@Component({
selector: 'app-example',
templateUrl: 'example.component.html',
styleUrls: ['example.component.css'],
imports: [IonProgressBar],
})
export class ExampleComponent {}
React
src/main.tsx
import React from 'react';
import { IonProgressBar } from '@ionic/react';
import './main.css';
function Example() {
return (
<>
<IonProgressBar value={0.25} buffer={0.5}></IonProgressBar>
<IonProgressBar type="indeterminate"></IonProgressBar>
</>
);
}
export default Example;
src/main.css
ion-progress-bar::part(track) {
background: #f3e895;
}
ion-progress-bar::part(progress) {
background: #09c567;
}
ion-progress-bar::part(stream) {
background-image: radial-gradient(ellipse at center, #e475f3 0%, #e475f3 30%, transparent 30%);
}
Vue
<template>
<ion-progress-bar value=".25" buffer=".5"></ion-progress-bar>
<ion-progress-bar type="indeterminate"></ion-progress-bar>
</template>
<script setup lang="ts">
import { IonProgressBar } from '@ionic/vue';
</script>
<style scoped>
ion-progress-bar::part(track) {
background: #f3e895;
}
ion-progress-bar::part(progress) {
background: #09c567;
}
ion-progress-bar::part(stream) {
background-image: radial-gradient(ellipse at center, #e475f3 0%, #e475f3 30%, transparent 30%);
}
</style>
Properties
buffer
설명: buffer와 value가 1보다 작으면 버퍼 원이 표시됩니다. buffer는 [0, 1] 사이여야 해요.
속성(Attribute): buffer
타입(Type): number
기본값(Default): 1
color
설명: 애플리케이션의 색상 팔레트에서 사용할 색상을 지정합니다. 기본 옵션은 "primary", "secondary", "tertiary", "success", "warning", "danger", "light", "medium", "dark"입니다. 색상에 대한 자세한 내용은 theming 문서를 참고하세요.
속성(Attribute): color
타입(Type): "danger" | "dark" | "light" | "medium" | "primary" | "secondary" | "success" | "tertiary" | "warning" | string | undefined
기본값(Default): undefined
mode
설명: mode는 어떤 플랫폼 스타일을 사용할지 결정합니다. 이는 virtual property로, 초기화 시 한 번 설정되며 첫 렌더링 후 값을 변경해도 업데이트되지 않습니다.
속성(Attribute): mode
타입(Type): "ios" | "md"
기본값(Default): undefined
reversed
설명: true로 설정하면 진행 표시줄 방향을 뒤집습니다.
속성(Attribute): reversed
타입(Type): boolean
기본값(Default): false
type
설명: 진행 표시줄의 상태로, 프로세스에 걸리는 시간을 아는지 여부에 따라 달라집니다. 기본 옵션은 "determinate"(애니메이션 없음)와 "indeterminate"(왼쪽에서 오른쪽으로 애니메이션)입니다.
속성(Attribute): type
타입(Type): "determinate" | "indeterminate"
기본값(Default): 'determinate'
value
설명: type이 "determinate"일 때 활성 막대가 얼마나 표시될지 결정하는 값입니다. value는 [0, 1] 사이여야 해요.
속성(Attribute): value
타입(Type): number
기본값(Default): 0
Events
이 컴포넌트에서 사용할 수 있는 이벤트가 없습니다.
Methods
이 컴포넌트에서 사용할 수 있는 공개 메서드가 없습니다.
CSS Shadow Parts
| 이름(Name) | 설명(Description) |
|---|---|
progress |
type이 "determinate"일 때 현재 값을 보여주고, "indeterminate"일 때 좌우로 움직이는 진행 막대입니다. |
stream |
버퍼링 중에 나타나는 애니메이션 원입니다. buffer가 설정되고 type이 "determinate"일 때만 표시됩니다. |
track |
진행 막대 뒤의 트랙 막대입니다. buffer 프로퍼티가 설정되고 type이 "determinate"라면 트랙은 buffer 값의 너비가 됩니다. |
CSS Custom Properties
iOS
| 이름(Name) | 설명(Description) |
|---|---|
--background |
진행 트랙의 배경 (버퍼가 설정되면 버퍼 막대) |
--progress-background |
현재 값을 나타내는 진행 막대의 배경 |
MD
| 이름(Name) | 설명(Description) |
|---|---|
--background |
진행 트랙의 배경 (버퍼가 설정되면 버퍼 막대) |
--progress-background |
현재 값을 나타내는 진행 막대의 배경 |
Slots
이 컴포넌트에서 사용할 수 있는 슬롯이 없습니다.
더 알아보기 (Learn more)
ion-progress-bar는 작업의 진행률을 보여주거나 진행 중임을 알려주는 컴포넌트예요. 진행률을 정확히 알 때는 determinate를, 기간을 모를 때는 indeterminate를 사용하세요. color나 --progress-background를 이용해 툴바와 자연스럽게 어울리게 꾸밀 수 있습니다.