UIPackage
Menu

Framework

Change language

Boilerplate repo

Alert

alertui

Static, in-flow notice block with a leading icon, title, and description. Use for inline page-level messages — info banners, success confirmations, warning callouts. Two tones: `default` and `destructive`.

Also available for React ->

Installation

$npx shadcn-vue@latest add https://uipkge.dev/r/vue/alert.json
Named registry:npx shadcn-vue@latest add @uipkge/alertInstalls to:app/components/ui/alert/

Examples

Loading interactive previews…

Props

NameType / ValuesDefaultRequired
classHTMLAttributes['class']optional
variant
'default''destructive'
optional
icon
'info''warning''error''success'
optional
titlestringoptional
textstringoptional

Used by

Files installed (5)

  • app/components/ui/alert/Alert.vue1.5 kB
    <script setup lang="ts">
    import type { HTMLAttributes } from 'vue'
    import { AlertCircle, CheckCircle, Info, TriangleAlert } from 'lucide-vue-next'
    import { cn } from '@/lib/utils'
    import { alertVariants } from './alert.variants'
    
    // Inlined union: SFC compiler can't extract runtime props from
    // `AlertVariants['variant']`.
    const props = defineProps<{
      class?: HTMLAttributes['class']
      variant?: 'default' | 'destructive'
      icon?: 'info' | 'warning' | 'error' | 'success'
      title?: string
      text?: string
    }>()
    </script>
    
    <template>
      <div role="alert" data-uipkge data-slot="alert" :class="cn(alertVariants({ variant }), props.class)">
        <!--
          Icons and composition children must be direct root descendants so the
          `[&>svg]` absolute layout in alertVariants can position and pad correctly.
        -->
        <AlertCircle v-if="icon === 'error'" class="size-4" aria-hidden="true" />
        <CheckCircle v-else-if="icon === 'success'" class="size-4" aria-hidden="true" />
        <TriangleAlert v-else-if="icon === 'warning'" class="size-4" aria-hidden="true" />
        <Info v-else-if="icon === 'info'" class="size-4" aria-hidden="true" />
    
        <p v-if="title" data-uipkge data-slot="alert-title" class="mb-1 text-sm leading-none font-medium tracking-tight">
          {{ title }}
        </p>
        <div
          v-if="text"
          data-uipkge
          data-slot="alert-description"
          class="text-muted-foreground text-sm leading-relaxed [&_p]:leading-relaxed"
        >
          {{ text }}
        </div>
        <slot />
      </div>
    </template>
    
  • app/components/ui/alert/AlertDescription.vue0.4 kB
  • app/components/ui/alert/AlertTitle.vue0.4 kB
  • app/components/ui/alert/alert.variants.ts1.1 kB
  • app/components/ui/alert/index.ts0.4 kB

Raw manifest:https://uipkge.dev/r/vue/alert.json