Skip to content

Alert ​

A neo-brutalist style alert component for displaying status messages, supporting 7 color variants.

Demo ​

Preview

Installation ​

pnpm dlx brutx-vue@latest add alert

Usage ​

vue
<script setup>
import { Alert, AlertTitle, AlertDescription } from 'brutx-ui-vue'
</script>

<template>
    <Alert variant="default">
        <AlertTitle>Heads up!</AlertTitle>
        <AlertDescription>You can add components to your app using the CLI.</AlertDescription>
    </Alert>
</template>

Variants ​

VariantDescription
defaultStandard background with foreground text
primaryPrimary (coral) background
secondarySecondary (mint) background
successSuccess (green) background
warningWarning (yellow) background
dangerDestructive (red) background
infoInfo (blue) background
vue
<script setup>
import { Alert } from 'brutx-ui-vue'
</script>

<template>
    <Alert variant="success">Operation completed successfully.</Alert>
    <Alert variant="danger">Failed to save changes.</Alert>
    <Alert variant="info">A new version is available.</Alert>
</template>

With Icon ​

Alert supports placing icons via SVG child elements. The icon is absolutely positioned on the left side:

vue
<script setup>
import { Alert, AlertTitle, AlertDescription } from 'brutx-ui-vue'
import { Terminal } from '@lucide/vue'
</script>

<template>
    <Alert variant="default">
        <Terminal class="h-5 w-5" />
        <AlertTitle>Terminal</AlertTitle>
        <AlertDescription>Run commands in your terminal.</AlertDescription>
    </Alert>
</template>

Closable Alert ​

Use the closable prop to render a close button in the top-right corner of the alert (using the Button component with variant="ghost" size="icon"). Clicking the button triggers the close event. When closable is enabled, the alert automatically adds right padding (pr-12) to prevent content from overlapping with the button.

vue
<script setup>
import { ref } from 'vue'
import { Alert, AlertTitle, AlertDescription } from 'brutx-ui-vue'

const visible = ref(true)

function handleClose() {
    visible.value = false
}
</script>

<template>
    <Alert v-if="visible" variant="info" closable @close="handleClose">
        <AlertTitle>Closable Alert</AlertTitle>
        <AlertDescription>Click the x button in the top-right corner to close this alert.</AlertDescription>
    </Alert>
</template>

Action Buttons ​

Use the actions named slot to add an action button area below the alert content. The slot content is rendered in a flex container with spacing (mt-3 flex items-center gap-2).

vue
<script setup>
import { Alert, AlertTitle, AlertDescription, Button } from 'brutx-ui-vue'
</script>

<template>
    <Alert variant="warning">
        <AlertTitle>Storage Space Low</AlertTitle>
        <AlertDescription>Your storage is 90% full. Please clean up or upgrade soon.</AlertDescription>
        <template #actions>
            <Button variant="primary" size="sm">Upgrade Now</Button>
            <Button variant="outline" size="sm">Remind Later</Button>
        </template>
    </Alert>
</template>

API Reference ​

Alert

Alert — Props
NameTypeDefaultDescription
variant
"danger-subtle" | "danger" | "default" | "info-subtle" | "info" | "primary-subtle" | "primary" | "secondary-subtle" | "secondary" | "success-subtle" | "success" | "warning-subtle" | "warning" | undefined
"default"
Controls the alert’s visual variant, including its border, foreground, and background colors.
Details

Declared type

NonNullable<"default" | "primary" | "secondary" | "success" | "warning" | "danger" | "info" | "primary-subtle" | "secondary-subtle" | "warning-subtle" | "danger-subtle" | "success-subtle" | "info-subtle" | null | undefined> | undefined

Literal values

  • "danger-subtle"
  • "danger"
  • "default"
  • "info-subtle"
  • "info"
  • "primary-subtle"
  • "primary"
  • "secondary-subtle"
  • "secondary"
  • "success-subtle"
  • "success"
  • "warning-subtle"
  • "warning"

Default value details

Declaration
'default'

Source: packages/ui/src/components/alert/Alert.vue

Resolved value
"default"

Source

Alert.vue:17

packages/ui/src/components/alert/Alert.vue

closable
boolean | undefined
false
Shows a close button in the top-right corner. Clicking it emits close.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
false

Source

Alert.vue:19

packages/ui/src/components/alert/Alert.vue

class
string | undefined
undefined
Additional CSS classes merged into the alert root element.
Details

Declared type

string | undefined

Default value details

Declaration
undefined

Source: packages/ui/src/components/alert/Alert.vue

Resolved value
undefined

Source

Alert.vue:20

packages/ui/src/components/alert/Alert.vue

Alert — Events
NameSignature or typeDescription
@close
[]
Emitted without a payload when the close button of a closable alert is clicked.
Details

Declared type

[]

Source

Alert.vue

packages/ui/src/components/alert/Alert.vue

Alert — Slots
NameSignature or typeDescription
#default
{}
The main alert content, typically a title, description, or other custom content.
Details

Declared type

{}

Source

Alert.vue

packages/ui/src/components/alert/Alert.vue

#actions
{}
An optional action area. When provided, its content appears below the main alert content.
Details

Declared type

{}

Source

Alert.vue

packages/ui/src/components/alert/Alert.vue

AlertDescription

AlertDescription — Props
NameTypeDefaultDescription
id
string | undefined
—
Sets the description element’s DOM id. If omitted, the component generates an id; when nested in Alert, that id is registered for aria-describedby.
Details

Declared type

string | undefined

Default value details

Not declared
—

Source

AlertDescription.vue:8

packages/ui/src/components/alert/AlertDescription.vue

class
string | undefined
—
Additional CSS classes merged into the description element.
Details

Declared type

string | undefined

Default value details

Not declared
—

Source

AlertDescription.vue:9

packages/ui/src/components/alert/AlertDescription.vue

AlertDescription — Slots
NameSignature or typeDescription
#default
{}
The alert description. When nested in Alert, its DOM id is included in the root’s aria-describedby relationship.
Details

Declared type

{}

Source

AlertDescription.vue

packages/ui/src/components/alert/AlertDescription.vue

AlertTitle

AlertTitle — Props
NameTypeDefaultDescription
as
AsTag | Component | undefined
"h5"
Selects the HTML element or Vue component used to render the title. The default is h5.
Details

Declared type

AsTag | Component | undefined

Literal values

  • "a"
  • "button"
  • "div"
  • "form"
  • "h2"
  • "h3"
  • "img"
  • "input"
  • "label"
  • "li"
  • "nav"
  • "ol"
  • "p"
  • "span"
  • "svg"
  • "template"
  • "ul"

Default value details

Resolved value
"h5"

Source

AlertTitle.vue:8

packages/ui/src/components/alert/AlertTitle.vue

asChild
boolean | undefined
undefined
Merges the title props, styles, and slot content into its single child; the child determines the rendered element when enabled.
Details

Declared type

boolean | undefined

Literal values

  • false
  • true

Default value details

Resolved value
undefined

Source

AlertTitle.vue:10

packages/ui/src/components/alert/AlertTitle.vue

class
string | undefined
undefined
Additional CSS classes merged into the title element.
Details

Declared type

string | undefined

Default value details

Resolved value
undefined

Source

AlertTitle.vue:11

packages/ui/src/components/alert/AlertTitle.vue

AlertTitle — Slots
NameSignature or typeDescription
#default
{}
The title text or other title content.
Details

Declared type

{}

Source

AlertTitle.vue

packages/ui/src/components/alert/AlertTitle.vue

Accessibility ​

  • ARIA Role: The component automatically sets role="alert" to ensure screen readers can identify and announce alert content
  • Keyboard Interaction: The close button of a closable alert supports Tab focus, Enter/Space to trigger close
  • Focus Management: The close button has a visible focus indicator, meeting keyboard navigation standards
  • Semantic Structure: AlertTitle renders as an h5 heading element by default, providing a clear content hierarchy

Brute force builds.