알림
알림 (Alert)
사용자의 주의를 끌기 위한 콜아웃(callout) 컴포넌트예요. 제목, 설명, 아이콘, 아바타, 액션 버튼, 닫기 버튼 등을 조합해 다양한 알림 스타일을 만들 수 있어요.
출처: Nuxt UI
본문
사용법 (Usage)
제목 (Title)
title prop을 사용해 Alert의 제목을 설정해요.
<template>
<UAlert title="Heads up!" />
</template>
설명 (Description)
description prop을 사용해 Alert의 설명을 설정해요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." />
</template>
아이콘 (Icon)
icon prop을 사용해 Icon을 표시해요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." icon="i-lucide-terminal" />
</template>
아바타 (Avatar)
avatar prop을 사용해 Avatar를 표시해요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." :avatar="{
src: 'https://github.com/nuxt.png'
}" />
</template>
색상 (Color)
color prop을 사용해 Alert의 색상을 변경해요.
<template>
<UAlert color="neutral" title="Heads up!" description="You can change the primary color in your app config." icon="i-lucide-terminal" />
</template>
변형 (Variant)
variant prop을 사용해 Alert의 변형을 변경해요.
<template>
<UAlert color="neutral" variant="subtle" title="Heads up!" description="You can change the primary color in your app config." icon="i-lucide-terminal" />
</template>
닫기 (Close)
close prop을 사용해 Alert를 닫는 Button을 표시해요.
[!TIP]
닫기 버튼을 클릭하면
update:open이벤트가 발생해요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." color="neutral" variant="outline" close />
</template>
Button 컴포넌트의 어떤 속성이든 전달해 버튼을 커스텀할 수 있어요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." color="neutral" variant="outline" :close="{
color: 'primary',
variant: 'outline',
class: 'rounded-full'
}" />
</template>
닫기 아이콘 (Close Icon)
close-icon prop을 사용해 닫기 버튼의 Icon을 커스텀해요. 기본값은 i-lucide-x예요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." color="neutral" variant="outline" close close-icon="i-lucide-arrow-right" />
</template>
Nuxt:
[!TIP] See: /docs/getting-started/integrations/icons/nuxt#theme
You can customize this icon globally in your
app.config.tsunderui.icons.closekey.
[!TIP]
이 아이콘은
app.config.ts의ui.icons.close키에서 전역으로 커스텀할 수 있어요. 자세한 내용은 /docs/getting-started/integrations/icons/nuxt#theme 문서를 참고해 주세요.
Vue:
[!TIP] See: /docs/getting-started/integrations/icons/vue#theme
You can customize this icon globally in your
vite.config.tsunderui.icons.closekey.
[!TIP]
이 아이콘은
vite.config.ts의ui.icons.close키에서 전역으로 커스텀할 수 있어요. 자세한 내용은 /docs/getting-started/integrations/icons/vue#theme 문서를 참고해 주세요.
액션 (Actions)
actions prop을 사용해 Alert에 여러 Button 액션을 추가할 수 있어요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." color="neutral" variant="outline" :actions="[
{
label: 'Action 1'
},
{
label: 'Action 2',
color: 'neutral',
variant: 'subtle'
}
]" />
</template>
방향 (Orientation)
orientation prop을 사용해 Alert의 방향을 변경해요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." color="neutral" variant="outline" orientation="horizontal" :actions="[
{
label: 'Action 1'
},
{
label: 'Action 2',
color: 'neutral',
variant: 'subtle'
}
]" />
</template>
예시 (Examples)
class prop
class prop을 사용해 Alert의 기본 스타일을 덮어쓸 수 있어요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." class="rounded-none" />
</template>
ui prop
ui prop을 사용해 Alert의 슬롯 스타일을 덮어쓸 수 있어요.
<template>
<UAlert title="Heads up!" description="You can change the primary color in your app config." icon="i-lucide-rocket" :ui="{
icon: 'size-11'
}" />
</template>
API
Props
/**
* Props for the Alert component
*/
interface AlertProps {
/**
* The element or component this component should render as.
* @default 'div'
*/
as?: any;
title?: string | undefined;
description?: string | undefined;
icon?: any;
avatar?: AvatarProps | undefined;
/**
* @default 'primary'
*/
color?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | undefined;
/**
* @default 'solid'
*/
variant?: "solid" | "outline" | "soft" | "subtle" | undefined;
/**
* The orientation between the content and the actions.
* @default 'vertical'
*/
orientation?: "vertical" | "horizontal" | undefined;
/**
* Display a list of actions:
* - under the title and description when orientation is `vertical`
* - next to the close button when orientation is `horizontal`
* `{ size: 'xs' }`{lang="ts-type"}
*/
actions?: ButtonProps[] | undefined;
/**
* Display a close button to dismiss the alert.
* `{ size: 'md', color: 'neutral', variant: 'link' }`{lang="ts-type"}
* @default false
*/
close?: boolean | Omit<ButtonProps, LinkPropsKeys> | undefined;
/**
* The icon displayed in the close button.
* @default appConfig.ui.icons.close
*/
closeIcon?: any;
ui?: { root?: SlotClass; wrapper?: SlotClass; title?: SlotClass; description?: SlotClass; icon?: SlotClass; avatar?: SlotClass; avatarSize?: SlotClass; actions?: SlotClass; close?: SlotClass; } | undefined;
}
Slots
/**
* Slots for the Alert component
*/
interface AlertSlots {
leading(): any;
title(): any;
description(): any;
actions(): any;
close(): any;
}
Emits
/**
* Emitted events for the Alert component
*/
interface AlertEmits {
update:open: (payload: [value: boolean]) => void;
}
테마 (Theme)
export default defineAppConfig({
ui: {
alert: {
slots: {
root: 'relative overflow-hidden w-full rounded-lg p-4 flex gap-2.5',
wrapper: 'min-w-0 flex-1 flex flex-col',
title: 'text-sm font-medium',
description: 'text-sm opacity-90',
icon: 'shrink-0 size-5',
avatar: 'shrink-0',
avatarSize: '2xl',
actions: 'flex flex-wrap gap-1.5 shrink-0',
close: 'p-0'
},
variants: {
color: {
primary: '',
secondary: '',
success: '',
info: '',
warning: '',
error: '',
neutral: ''
},
variant: {
solid: '',
outline: '',
soft: '',
subtle: ''
},
orientation: {
horizontal: {
root: 'items-center',
actions: 'items-center'
},
vertical: {
root: 'items-start',
actions: 'items-start mt-2.5'
}
},
title: {
true: {
description: 'mt-1'
}
}
},
compoundVariants: [
{
color: 'primary',
variant: 'solid',
class: {
root: 'bg-primary text-inverted'
}
},
{
color: 'secondary',
variant: 'solid',
class: {
root: 'bg-secondary text-inverted'
}
},
{
color: 'success',
variant: 'solid',
class: {
root: 'bg-success text-inverted'
}
},
{
color: 'info',
variant: 'solid',
class: {
root: 'bg-info text-inverted'
}
},
{
color: 'warning',
variant: 'solid',
class: {
root: 'bg-warning text-inverted'
}
},
{
color: 'error',
variant: 'solid',
class: {
root: 'bg-error text-inverted'
}
},
{
color: 'primary',
variant: 'outline',
class: {
root: 'text-primary ring ring-inset ring-primary/25'
}
},
{
color: 'secondary',
variant: 'outline',
class: {
root: 'text-secondary ring ring-inset ring-secondary/25'
}
},
{
color: 'success',
variant: 'outline',
class: {
root: 'text-success ring ring-inset ring-success/25'
}
},
{
color: 'info',
variant: 'outline',
class: {
root: 'text-info ring ring-inset ring-info/25'
}
},
{
color: 'warning',
variant: 'outline',
class: {
root: 'text-warning ring ring-inset ring-warning/25'
}
},
{
color: 'error',
variant: 'outline',
class: {
root: 'text-error ring ring-inset ring-error/25'
}
},
{
color: 'primary',
variant: 'soft',
class: {
root: 'bg-primary/10 text-primary'
}
},
{
color: 'secondary',
variant: 'soft',
class: {
root: 'bg-secondary/10 text-secondary'
}
},
{
color: 'success',
variant: 'soft',
class: {
root: 'bg-success/10 text-success'
}
},
{
color: 'info',
variant: 'soft',
class: {
root: 'bg-info/10 text-info'
}
},
{
color: 'warning',
variant: 'soft',
class: {
root: 'bg-warning/10 text-warning'
}
},
{
color: 'error',
variant: 'soft',
class: {
root: 'bg-error/10 text-error'
}
},
{
color: 'primary',
variant: 'subtle',
class: {
root: 'bg-primary/10 text-primary ring ring-inset ring-primary/25'
}
},
{
color: 'secondary',
variant: 'subtle',
class: {
root: 'bg-secondary/10 text-secondary ring ring-inset ring-secondary/25'
}
},
{
color: 'success',
variant: 'subtle',
class: {
root: 'bg-success/10 text-success ring ring-inset ring-success/25'
}
},
{
color: 'info',
variant: 'subtle',
class: {
root: 'bg-info/10 text-info ring ring-inset ring-info/25'
}
},
{
color: 'warning',
variant: 'subtle',
class: {
root: 'bg-warning/10 text-warning ring ring-inset ring-warning/25'
}
},
{
color: 'error',
variant: 'subtle',
class: {
root: 'bg-error/10 text-error ring ring-inset ring-error/25'
}
},
{
color: 'neutral',
variant: 'solid',
class: {
root: 'text-inverted bg-inverted'
}
},
{
color: 'neutral',
variant: 'outline',
class: {
root: 'text-highlighted bg-default ring ring-inset ring-default'
}
},
{
color: 'neutral',
variant: 'soft',
class: {
root: 'text-highlighted bg-elevated/50'
}
},
{
color: 'neutral',
variant: 'subtle',
class: {
root: 'text-highlighted bg-elevated/50 ring ring-inset ring-accented'
}
}
],
defaultVariants: {
color: 'primary',
variant: 'solid'
}
}
}
})
변경 내역 (Changelog)
사이트맵 (Sitemap)
전체 사이트맵에서 모든 페이지를 확인할 수 있어요.