스피드 다이얼
스피드 다이얼 (Speed Dial)
SpeedDial은 화면에 떠 있는 버튼을 누르면 메뉴 항목이 팝업으로 펼쳐지는 플로팅 버튼 컴포넌트예요. type 속성에 따라 항목을 선형, 원형, 반원, 사분원 형태로 배치할 수 있고, 툴팁과 커스텀 템플릿도 지원해요. 문서에서는 스크린 리더 접근성과 model 기반 메뉴 구성 방법부터 Props·Emits·Templates 같은 API, 패스 스루 옵션, CSS 클래스와 디자인 토큰을 활용한 테마 설정까지 설명해요.
출처: 문서
본문
접근성
스크린 리더에서 SpeedDial 컴포넌트는 전달된 모든 프로퍼티를 암묵적으로 포함하는 네이티브 button 엘리먼트를 렌더링해요. 버튼을 설명하는 텍스트는 aria-labelledby 또는 aria-label 프로퍼티로 정의할 수 있어요. 추가로 버튼에는 상태를 나타내는 aria-haspopup, aria-expanded와 함께 팝업과 버튼 사이의 관계를 정의하는 aria-controls도 포함돼요. 팝업 오버레이는 목록에 menu role을 사용하고, 각 액션 아이템은 menuitem role을 가지며 aria-label이 menuitem의 라벨로 사용돼요. 메뉴의 id는 버튼의 aria-controls에서 참조돼요.
원형
type을 circle로 설정하면 아이템을 버튼 주위에 표시할 수 있어요. 추가로 radius 프로퍼티는 원의 반지름을 정의해요.
import { Component, OnInit, inject } from '@angular/core';
import { SpeedDialModule } from 'primeng/speeddial';
import { ToastModule } from 'primeng/toast';
import { MenuItem, MessageService } from 'primeng/api';
@Component({
template: `
<div class="card">
<div style="position:relative; height: 500px;" class="flex items-center justify-center">
<p-toast />
<p-speeddial [model]="items" [radius]="80" type="circle" [style]="{ position: 'absolute' }" [buttonProps]="{ severity: 'warn', rounded: true }" />
</div>
</div>
`,
standalone: true,
imports: [SpeedDialModule, ToastModule],
providers: [MessageService]
})
export class SpeeddialCircleDemo implements OnInit {
private messageService = inject(MessageService);
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
icon: 'pi pi-pencil',
command: () => {
this.messageService.add({ severity: 'info', summary: 'Add', detail: 'Data Added' });
}
},
{
icon: 'pi pi-refresh',
command: () => {
this.messageService.add({ severity: 'success', summary: 'Update', detail: 'Data Updated' });
}
},
{
icon: 'pi pi-trash',
command: () => {
this.messageService.add({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' });
}
},
{
icon: 'pi pi-upload',
routerLink: ['/fileupload']
},
{
icon: 'pi pi-external-link',
target: '_blank',
url: 'https://angular.dev'
}
];
}
}
선형
SpeedDial 아이템은 MenuModel API를 기반으로 model 프로퍼티로 정의돼요. 아이템의 기본 방향은 linear이고, direction 프로퍼티는 버튼을 기준으로 아이템의 위치를 정의하는 데 사용돼요.
import { Component, OnInit, inject } from '@angular/core';
import { SpeedDialModule } from 'primeng/speeddial';
import { ToastModule } from 'primeng/toast';
import { MenuItem, MessageService } from 'primeng/api';
@Component({
template: `
<div class="card">
<div style="height: 500px; position: relative;">
<p-toast />
<p-speeddial [model]="items" direction="up" [style]="{ position: 'absolute', left: 'calc(50% - 2rem)', bottom: 0 }" />
<p-speeddial [model]="items" direction="down" [style]="{ position: 'absolute', left: 'calc(50% - 2rem)', top: 0 }" />
<p-speeddial [model]="items" direction="left" [style]="{ position: 'absolute', top: 'calc(50% - 2rem)', right: 0 }" />
<p-speeddial [model]="items" direction="right" [style]="{ position: 'absolute', top: 'calc(50% - 2rem)', left: 0 }" />
</div>
</div>
`,
standalone: true,
imports: [SpeedDialModule, ToastModule],
providers: [MessageService]
})
export class SpeeddialLinearDemo implements OnInit {
private messageService = inject(MessageService);
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
icon: 'pi pi-pencil',
command: () => {
this.messageService.add({ severity: 'info', summary: 'Add', detail: 'Data Added' });
}
},
{
icon: 'pi pi-refresh',
command: () => {
this.messageService.add({ severity: 'success', summary: 'Update', detail: 'Data Updated' });
}
},
{
icon: 'pi pi-trash',
command: () => {
this.messageService.add({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' });
}
},
{
icon: 'pi pi-upload',
routerLink: ['/fileupload']
},
{
icon: 'pi pi-external-link',
target: '_blank',
url: 'https://angular.dev'
}
];
}
}
마스크
mask 프로퍼티를 추가하면 팝업 아이템 뒤에 모달 레이어가 표시돼요.
import { Component, OnInit, inject } from '@angular/core';
import { SpeedDialModule } from 'primeng/speeddial';
import { ToastModule } from 'primeng/toast';
import { MenuItem, MessageService } from 'primeng/api';
@Component({
template: `
<div class="card p-4">
<div [style]="{ position: 'relative', height: '350px' }">
<p-toast />
<p-speeddial [model]="items" direction="up" mask [style]="{ position: 'absolute', right: '1rem', bottom: '1rem' }" />
</div>
</div>
`,
standalone: true,
imports: [SpeedDialModule, ToastModule],
providers: [MessageService]
})
export class SpeeddialMaskDemo implements OnInit {
private messageService = inject(MessageService);
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
icon: 'pi pi-pencil',
command: () => {
this.messageService.add({ severity: 'info', summary: 'Add', detail: 'Data Added' });
}
},
{
icon: 'pi pi-refresh',
command: () => {
this.messageService.add({ severity: 'success', summary: 'Update', detail: 'Data Updated' });
}
},
{
icon: 'pi pi-trash',
command: () => {
this.messageService.add({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' });
}
},
{
icon: 'pi pi-upload',
routerLink: ['/fileupload']
},
{
icon: 'pi pi-external-link',
target: '_blank',
url: 'https://angular.dev'
}
];
}
}
사분원
type이 quarter-circle로 정의되면 아이템이 버튼 주위에 반원 형태로 표시돼요.
import { Component, OnInit, inject } from '@angular/core';
import { SpeedDialModule } from 'primeng/speeddial';
import { ToastModule } from 'primeng/toast';
import { MenuItem, MessageService } from 'primeng/api';
@Component({
template: `
<div class="card">
<div style="position: relative; height: 500px">
<p-toast />
<p-speeddial [model]="items" [radius]="120" type="quarter-circle" direction="up-left" [style]="{ position: 'absolute', right: 0, bottom: 0 }" />
<p-speeddial [model]="items" [radius]="120" type="quarter-circle" direction="up-right" [style]="{ position: 'absolute', left: 0, bottom: 0 }" />
<p-speeddial [model]="items" [radius]="120" type="quarter-circle" direction="down-left" [style]="{ position: 'absolute', right: 0, top: 0 }" />
<p-speeddial [model]="items" [radius]="120" type="quarter-circle" direction="down-right" [style]="{ position: 'absolute', left: 0, top: 0 }" />
</div>
</div>
`,
standalone: true,
imports: [SpeedDialModule, ToastModule],
providers: [MessageService]
})
export class SpeeddialQuartercircleDemo implements OnInit {
private messageService = inject(MessageService);
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
icon: 'pi pi-pencil',
command: () => {
this.messageService.add({ severity: 'info', summary: 'Add', detail: 'Data Added' });
}
},
{
icon: 'pi pi-refresh',
command: () => {
this.messageService.add({ severity: 'success', summary: 'Update', detail: 'Data Updated' });
}
},
{
icon: 'pi pi-trash',
command: () => {
this.messageService.add({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' });
}
},
{
icon: 'pi pi-upload',
routerLink: ['/fileupload']
},
{
icon: 'pi pi-external-link',
target: '_blank',
url: 'https://angular.dev'
}
];
}
}
반원
type이 semi-circle로 정의되면 아이템이 버튼 주위에 반원 형태로 표시돼요.
import { Component, OnInit, inject } from '@angular/core';
import { SpeedDialModule } from 'primeng/speeddial';
import { ToastModule } from 'primeng/toast';
import { MenuItem, MessageService } from 'primeng/api';
@Component({
template: `
<div class="card">
<div style="position: relative; height: 500px">
<p-toast />
<p-speeddial [model]="items" [radius]="80" type="semi-circle" direction="down" [style]="{ position: 'absolute', left: 'calc(50% - 2rem)', top: 0 }" />
<p-speeddial [model]="items" [radius]="80" type="semi-circle" direction="right" [style]="{ position: 'absolute', top: 'calc(50% - 2rem)', left: 0 }" />
<p-speeddial [model]="items" [radius]="80" type="semi-circle" direction="left" [style]="{ position: 'absolute', top: 'calc(50% - 2rem)', right: 0 }" />
<p-speeddial [model]="items" [radius]="80" type="semi-circle" direction="up" [style]="{ position: 'absolute', left: 'calc(50% - 2rem)', bottom: 0 }" />
</div>
</div>
`,
standalone: true,
imports: [SpeedDialModule, ToastModule],
providers: [MessageService]
})
export class SpeeddialSemicircleDemo implements OnInit {
private messageService = inject(MessageService);
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
icon: 'pi pi-pencil',
command: () => {
this.messageService.add({ severity: 'info', summary: 'Add', detail: 'Data Added' });
}
},
{
icon: 'pi pi-refresh',
command: () => {
this.messageService.add({ severity: 'success', summary: 'Update', detail: 'Data Updated' });
}
},
{
icon: 'pi pi-trash',
command: () => {
this.messageService.add({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' });
}
},
{
icon: 'pi pi-upload',
routerLink: ['/fileupload']
},
{
icon: 'pi pi-external-link',
target: '_blank',
url: 'https://angular.dev'
}
];
}
}
템플릿
SpeedDial은 model에서 menuitem 인스턴스를 파라미터로 전달받는 item 템플릿을 통해 아이템 커스터마이징을 제공해요. 버튼은 자체적인 button 템플릿을 가지고 있고, 기본 버튼에 아이콘 콘텐츠를 담을 수 있도록 icon이라는 이름의 추가 템플릿도 제공돼요.
import { Component, OnInit, inject } from '@angular/core';
import { ButtonModule } from 'primeng/button';
import { SpeedDialModule } from 'primeng/speeddial';
import { ToastModule } from 'primeng/toast';
import { MenuItem, MessageService } from 'primeng/api';
@Component({
template: `
<div class="card">
<div class="flex items-end justify-center" style="position: 'relative'; height: '400px'">
<p-toast />
<p-speeddial [model]="items" direction="up" [transitionDelay]="80" style="position: 'absolute'">
<ng-template #button let-toggleCallback="toggleCallback">
<p-button outlined styleClass="border" (click)="toggleCallback($event)">
<svg width="31" height="33" viewBox="0 0 31 33" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15.1934 0V0V0L0.0391235 5.38288L2.35052 25.3417L15.1934 32.427V32.427V32.427L28.0364 25.3417L30.3478 5.38288L15.1934 0Z" fill="var(--p-primary-color)" />
<mask id="mask0_1_52" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="31" height="33">
<path d="M15.1934 0V0V0L0.0391235 5.38288L2.35052 25.3417L15.1934 32.427V32.427V32.427L28.0364 25.3417L30.3478 5.38288L15.1934 0Z" fill="var(--ground-background)" />
</mask>
<g mask="url(#mask0_1_52)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M15.1935 0V3.5994V3.58318V20.0075V20.0075V32.427V32.427L28.0364 25.3417L30.3478 5.38288L15.1935 0Z" fill="var(--p-primary-color)" />
</g>
<path d="M19.6399 15.3776L18.1861 15.0547L19.3169 16.6695V21.6755L23.1938 18.4458V12.9554L21.4169 13.6013L19.6399 15.3776Z" fill="var(--ground-background)" />
<path d="M10.5936 15.3776L12.0474 15.0547L10.9166 16.6695V21.6755L7.03966 18.4458V12.9554L8.81661 13.6013L10.5936 15.3776Z" fill="var(--ground-background)" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M11.3853 16.9726L12.6739 15.0309L13.4793 15.5163H16.7008L17.5061 15.0309L18.7947 16.9726V24.254L17.8283 25.7103L16.7008 26.843H13.4793L12.3518 25.7103L11.3853 24.254V16.9726Z"
fill="var(--ground-background)"
/>
<path d="M19.3168 24.7437L21.4168 22.6444V20.5451L19.3168 22.3214V24.7437Z" fill="var(--ground-background)" />
<path d="M10.9166 24.7437L8.81662 22.6444V20.5451L10.9166 22.3214V24.7437Z" fill="var(--ground-background)" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M13.0167 5.68861L11.7244 8.7568L13.8244 14.8932H14.7936V5.68861H13.0167ZM15.4397 5.68861V14.8932H16.5706L18.5091 8.7568L17.2167 5.68861H15.4397Z"
fill="var(--ground-background)"
/>
<path d="M13.8244 14.8932L6.87813 12.3094L5.90888 8.27235L11.8859 8.7568L13.9859 14.8932H13.8244Z" fill="var(--ground-background)" />
<path d="M16.5706 14.8932L23.5169 12.3094L24.4861 8.27235L18.3476 8.7568L16.4091 14.8932H16.5706Z" fill="var(--ground-background)" />
<path d="M18.8321 8.27235L22.2245 7.94938L19.9629 5.68861H17.7013L18.8321 8.27235Z" fill="var(--ground-background)" />
<path d="M11.4013 8.27235L8.00893 7.94938L10.2705 5.68861H12.5321L11.4013 8.27235Z" fill="var(--ground-background)" />
</svg>
</p-button>
</ng-template>
<ng-template #item let-item let-toggleCallback="toggleCallback">
<div class="flex flex-col items-center justify-between gap-2 p-2 border rounded border-surface-200 dark:border-surface-700 w-20 cursor-pointer" (click)="toggleCallback($event, item)">
<span [class]="item.icon"></span>
<span>
{{ item.label }}
</span>
</div>
</ng-template>
</p-speeddial>
</div>
</div>
`,
standalone: true,
imports: [ButtonModule, SpeedDialModule, ToastModule],
providers: [MessageService]
})
export class SpeeddialTemplateDemo implements OnInit {
private messageService = inject(MessageService);
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
label: 'Add',
icon: 'pi pi-pencil',
command: () => {
this.messageService.add({ severity: 'info', summary: 'Add', detail: 'Data Added' });
}
},
{
label: 'Update',
icon: 'pi pi-refresh',
command: () => {
this.messageService.add({ severity: 'success', summary: 'Update', detail: 'Data Updated' });
}
},
{
label: 'Delete',
icon: 'pi pi-trash',
command: () => {
this.messageService.add({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' });
}
},
{
label: 'Upload',
icon: 'pi pi-upload',
command: () => {
this.router.navigate(['/fileupload']);
}
},
{
label: 'Website',
icon: 'pi pi-external-link',
command: () => {
window.open('https://angular.io/', '_blank');
}
}
];
}
}
툴팁
아이템과 일치하는 target을 가진 standalone Tooltip이 있으면, 아이템을 호버할 때 툴팁이 표시돼요.
import { Component, OnInit, inject } from '@angular/core';
import { SpeedDialModule } from 'primeng/speeddial';
import { ToastModule } from 'primeng/toast';
import { MenuItem, MessageService } from 'primeng/api';
@Component({
template: `
<div class="card">
<div [style]="{ position: 'relative', height: '350px' }">
<p-toast />
<p-speeddial [model]="items" direction="up" [style]="{ position: 'absolute', right: 0, bottom: 0 }" [buttonProps]="{ severity: 'help', rounded: true }" [tooltipOptions]="{ tooltipPosition: 'left' }" />
<p-speeddial [model]="items" direction="up" [style]="{ position: 'absolute', left: 0, bottom: 0 }" [buttonProps]="{ severity: 'danger', rounded: true }" [tooltipOptions]="{ tooltipPosition: 'right' }" />
</div>
</div>
`,
standalone: true,
imports: [SpeedDialModule, ToastModule],
providers: [MessageService]
})
export class SpeeddialTooltipDemo implements OnInit {
private messageService = inject(MessageService);
items: MenuItem[] | undefined;
ngOnInit() {
this.items = [
{
label: 'Add',
icon: 'pi pi-pencil',
command: () => {
this.messageService.add({ severity: 'info', summary: 'Add', detail: 'Data Added' });
}
},
{
label: 'Update',
icon: 'pi pi-refresh',
command: () => {
this.messageService.add({ severity: 'success', summary: 'Update', detail: 'Data Updated' });
}
},
{
label: 'Delete',
icon: 'pi pi-trash',
command: () => {
this.messageService.add({ severity: 'error', summary: 'Delete', detail: 'Data Deleted' });
}
},
{
label: 'Upload',
icon: 'pi pi-upload',
command: () => {
this.router.navigate(['/fileupload']);
}
},
{
label: 'Angular.dev',
icon: 'pi pi-external-link',
target: '_blank',
url: 'https://angular.dev'
}
];
}
}
Speed Dial
눌렀을 때, 플로팅 액션 버튼은 페이지에서 수행할 수 있는 여러 주요 액션을 표시할 수 있어요.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| dt | InputSignal | undefined | 컴포넌트의 스코프 디자인 토큰을 정의해요. |
| unstyled | InputSignal | undefined | 컴포넌트를 스타일 없이 렌더링할지 여부를 나타내요. |
| pt | InputSignal | undefined | 컴포넌트 내부의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| ptOptions | InputSignal | undefined | 컴포넌트의 passthrough(pt) 옵션을 구성하는 데 사용돼요. |
| id | string | - | 아이템 목록의 id예요. |
| model | MenuItem[] | null | 액션 아이템을 정의하는 MenuModel 인스턴스예요. |
| visible | boolean | - | 오버레이의 표시 여부를 지정해요. |
| style | { [klass: string]: any } | - | 요소의 인라인 스타일이에요. |
| className | string | - | 요소의 스타일 클래스예요. |
| transitionDelay | number | 30 | 각 액션 아이템의 트랜지션 지연 단계예요. |
| type | "circle" | "linear" | "semi-circle" | "quarter-circle" | linear | 액션이 열리는 방식을 지정해요. |
| radius | number | 0 | *circle 타입의 반지름이에요. |
| mask | boolean | false | speeddial 뒤에 마스크 요소를 표시할지 여부예요. |
| disabled | boolean | false | 컴포넌트의 비활성화 여부예요. |
| hideOnClickOutside | boolean | true | 바깥을 클릭하면 액션이 닫히는지 여부예요. |
| buttonStyle | { [klass: string]: any } | - | 버튼 요소의 인라인 스타일이에요. |
| buttonClassName | string | - | 버튼 요소의 스타일 클래스예요. |
| maskStyle | { [klass: string]: any } | - | 마스크 요소의 인라인 스타일이에요. |
| maskClassName | string | - | 마스크 요소의 스타일 클래스예요. |
| showIcon | string | - | 버튼 요소의 표시 아이콘이에요. |
| hideIcon | string | - | 버튼 요소의 숨김 아이콘이에요. |
| rotateAnimation | boolean | true | hideIcon이 없을 때 showIcon을 회전시키도록 정의해요. |
| ariaLabel | string | - | 인터랙티브 요소에 라벨을 지정하는 문자열 값을 정의해요. |
| ariaLabelledBy | string | - | 기반이 되는 input 요소의 식별자예요. |
| tooltipOptions | TooltipOptions | - | 아이템에 툴팁을 표시할지 여부예요. Tooltip의 modifiers를 객체 형태로 여기에 사용할 수 있어요. 유효한 키는 'event'와 'position'이에요. |
| buttonProps | ButtonProps | - | ButtonProps의 모든 프로퍼티를 Button 컴포넌트에 전달하는 데 사용돼요. |
Emits
| Name | Parameters | Description |
|---|---|---|
| onVisibleChange | value: boolean | 요소의 표시 여부가 변경됐을 때 발생해요. |
| visibleChange | value: boolean | 요소의 표시 여부가 변경됐을 때 발생해요. |
| onClick | event: MouseEvent | 버튼 요소가 클릭됐을 때 발생해요. |
| onShow | event: Event | 액션이 표시됐을 때 발생해요. |
| onHide | event: Event | 액션이 숨겨졌을 때 발생해요. |
Templates
| Name | Type | Description |
|---|---|---|
| button | TemplateRef | 커스텀 버튼 템플릿이에요. |
| item | TemplateRef | 커스텀 아이템 템플릿이에요. |
| icon | TemplateRef | 커스텀 아이콘 템플릿이에요. |
Pass Through Options
| Name | Type | Description |
|---|---|---|
| root | PassThroughOption<HTMLDivElement, I> | root의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| pcButton | ButtonPassThrough | Button 컴포넌트에 속성을 전달하는 데 사용돼요. |
| list | PassThroughOption<HTMLUListElement, I> | list의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| item | PassThroughOption<HTMLLIElement, I> | item의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| pcAction | ButtonPassThrough | action의 Button 컴포넌트에 속성을 전달하는 데 사용돼요. |
| actionIcon | PassThroughOption<HTMLSpanElement, I> | action icon의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| mask | PassThroughOption<HTMLDivElement, I> | mask의 DOM 요소에 속성을 전달하는 데 사용돼요. |
테마
CSS 클래스
| 클래스 | 설명 |
|---|---|
| p-speeddial | 루트 엘리먼트의 클래스 이름이에요 |
| p-speeddial-button | 버튼 엘리먼트의 클래스 이름이에요 |
| p-speeddial-list | 리스트 엘리먼트의 클래스 이름이에요 |
| p-speeddial-item | 아이템 엘리먼트의 클래스 이름이에요 |
| p-speeddial-action | 액션 엘리먼트의 클래스 이름이에요 |
| p-speeddial-action-icon | 액션 아이콘 엘리먼트의 클래스 이름이에요 |
| p-speeddial-mask | 마스크 엘리먼트의 클래스 이름이에요 |
디자인 토큰
| 토큰 | CSS 변수 | 설명 |
|---|---|---|
| speeddial.gap | --p-speeddial-gap | 루트의 간격이에요 |
| speeddial.transition.duration | --p-speeddial-transition-duration | 루트의 트랜지션 지속 시간이에요 |
더 알아보기 (Learn more)
이 문서에는 원문에서 추출한 별도의 관련 문서 링크가 없어요.