Alert

A component to display important messages and notifications to users

Variants


Code Svelte
1
2<script lang="ts">
3	import { Alert } from "@kareyes/aether";
4
5</script>
6
7<div class="space-y-4">
8    <Alert variant="default" title="Default Alert" description="This is a default alert message." />
9    <Alert variant="info" title="Information" description="This is an informational message to keep you updated." />
10    <Alert variant="success" title="Success" description="Your changes have been saved successfully." />
11    <Alert variant="warning" title="Warning" description="Please review your settings before proceeding." />
12    <Alert variant="error" title="Error" description="Something went wrong. Please try again." />
13    
14</div>
15

With and Without Icons


Code Svelte
1
2<script lang="ts">
3    import { Alert } from "@kareyes/aether";
4</script>
5
6<div class="space-y-4">
7    <Alert 
8        variant="info" 
9        title="With Icon" 
10        description="This alert displays the default variant icon." 
11        showIcon={true}
12    />
13    <Alert 
14        variant="success" 
15        title="Without Icon" 
16        description="This alert hides the icon for a cleaner look." 
17        showIcon={false}
18    />
19</div>

Dismissible Alerts

Click the X button to dismiss these alerts.


Code Svelte
1
2<script lang="ts">
3    import { Alert } from "@kareyes/aether";
4</script>
5
6<div class="space-y-4">
7    <Alert 
8        variant="info" 
9        title="Dismissible Info" 
10        description="You can dismiss this alert." 
11        dismissible={true}
12    />
13    <Alert 
14        variant="warning" 
15        title="Dismissible Warning" 
16        description="Click the X to close this warning." 
17        dismissible={true}
18    />
19</div>

With Action Buttons


Code Svelte
1
2<script lang="ts">
3    import { Alert, Button } from "@kareyes/aether";
4</script>
5
6<div class="space-y-4">
7    <Alert variant="warning" title="Pending Changes" description="You have unsaved changes in your document.">
8        {#snippet actions()}
9            <Button variant="outline" size="sm">Discard</Button>
10            <Button size="sm" color="warning" variant="flat">Save Changes</Button>
11        {/snippet}
12    </Alert>
13
14    <Alert variant="error" title="Connection Lost" description="We couldn't connect to the server.">
15        {#snippet actions()}
16            <Button variant="outline" size="sm">Cancel</Button>
17            <Button size="sm" color="danger" variant="flat">Retry</Button>
18        {/snippet}
19    </Alert>
20
21    <Alert variant="success" title="Update Available" description="A new version of the application is ready to install.">
22        {#snippet actions()}
23            <Button variant="outline" size="sm">Later</Button>
24            <Button size="sm" color="success" variant="flat">Install Now</Button>
25        {/snippet}
26    </Alert>
27</div>

Custom Content


Code Svelte
1
2<script lang="ts">
3   	import { AlertPrimitives } from "@kareyes/aether";
4   
5</script>
6
7<div class="space-y-4">
8    <AlertPrimitives.Root variant="info">
9        {#snippet icon()}
10            <svg class="size-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
11                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
12            </svg>
13        {/snippet}
14        <AlertPrimitives.Title>Scheduled Maintenance</AlertPrimitives.Title>
15        <AlertPrimitives.Description>
16            The system will undergo scheduled maintenance on Sunday at 2:00 AM UTC.
17        </AlertPrimitives.Description>
18    </AlertPrimitives.Root>
19
20    <AlertPrimitives.Root variant="success">
21        {#snippet icon()}
22            <svg class="size-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
23                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" />
24            </svg>
25        {/snippet}
26        <AlertPrimitives.Title>Verification Complete</AlertPrimitives.Title>
27        <AlertPrimitives.Description>
28            Your account has been verified successfully.
29        </AlertPrimitives.Description>
30    </AlertPrimitives.Root>
31</div>

Complex Examples


Code Svelte
1
2<script lang="ts">
3    import { AlertPrimitives, Button } from "@kareyes/aether";
4</script>
5
6<div class="space-y-4">
7    <AlertPrimitives.Root variant="warning" dismissible={true}>
8        {#snippet icon()}
9            <svg class="size-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
10                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
11            </svg>
12        {/snippet}
13        <AlertPrimitives.Title>Storage Almost Full</AlertPrimitives.Title>
14        <AlertPrimitives.Description>
15            You're using 95% of your storage quota. Upgrade your plan or delete files to continue.
16        </AlertPrimitives.Description>
17        {#snippet actions()}
18            <Button variant="outline" size="sm">Manage Files</Button>
19            <Button size="sm">Upgrade Plan</Button>
20        {/snippet}
21    </AlertPrimitives.Root>
22
23    <AlertPrimitives.Root variant="error">
24        {#snippet icon()}
25            <svg class="size-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
26                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
27            </svg>
28        {/snippet}
29        <AlertPrimitives.Title>Payment Failed</AlertPrimitives.Title>
30        <AlertPrimitives.Description>
31            <p>Your payment could not be processed. Please check the following:</p>
32            <ul class="list-disc list-inside mt-2 space-y-1">
33                <li>Card details are correct</li>
34                <li>Sufficient funds are available</li>
35                <li>Card is not expired</li>
36            </ul>
37        </AlertPrimitives.Description>
38        {#snippet actions()}
39            <Button variant="outline" size="sm">Contact Support</Button>
40            <Button size="sm">Try Again</Button>
41        {/snippet}
42    </AlertPrimitives.Root>
43</div>

Compact Layout

Alerts with just titles or descriptions.


Code Svelte
1
2<script lang="ts">
3    import { Alert } from "@kareyes/aether";
4</script>
5
6<div class="space-y-4">
7    <Alert variant="info" title="Quick update available" />
8    <Alert variant="success" description="File uploaded successfully" />
9    <Alert variant="warning" title="Low disk space" />
10</div>

Real-World Examples


Code Svelte
1
2<script lang="ts">
3    import { Alert, Button } from "@kareyes/aether";
4</script>
5
6<div class="space-y-4">
7<!-- Cookie Notice -->
8<Alert variant="default" title="Cookie Notice" dismissible={true}>
9    {#snippet actions()}
10        <Button variant="outline" size="sm">Decline</Button>
11        <Button size="sm">Accept</Button>
12    {/snippet}
13</Alert>
14
15<!-- Newsletter Signup -->
16<Alert variant="info" title="Stay Updated" description="Subscribe to our newsletter for the latest updates.">
17    {#snippet actions()}
18        <Button size="sm">Subscribe</Button>
19    {/snippet}
20</Alert>
21
22<!-- Security Alert -->
23<Alert variant="error" title="Security Alert" description="Unusual login activity detected from a new location." dismissible={false}>
24    {#snippet actions()}
25        <Button variant="outline" size="sm">It Was Me</Button>
26        <Button size="sm">Secure Account</Button>
27    {/snippet}
28</Alert>
29</div>