suiss/ui
  • Docs
  • Components
  • Patterns
  • Interactions
  • Charts
  • Blocks
  • AI
GitHubCreate
DocsComponentsPatternsInteractionsChartsBlocksAICreate
Components84
  • Overview
  • Accordion
  • Alert
  • Alert Dialog
  • Alert Sheet
  • Amount Input
  • Aspect Ratio
  • Attachment
  • Avatar
  • Badge
  • Bottom Bar
  • Breadcrumb
  • Bubble
  • Button
  • Button Group
  • Calendar
  • Card
  • Carousel
  • Chart
  • Checkbox
  • Chip
  • Code Block
  • Collapsible
  • Combobox
  • Command
  • Context Menu
  • Dialog
  • Direction
  • Drawer
  • Dropdown Menu
  • Empty
  • FAB
  • Field
  • Fullscreen Menu
  • Haptics
  • Header
  • Hover Card
  • Icon
  • Input
  • Input Accessory Bar
  • Input Group
  • Input OTP
  • Item
  • Kbd
  • Keyboard Scroll View
  • Keypad
  • Label
  • Marker
  • Menubar
  • Message
  • Message Scroller
  • Native Select
  • Navigation Menu
  • Page Indicator
  • Pagination
  • Pin Pad
  • Popover
  • Progress
  • QR Scanner
  • Questionnaire
  • Radio Group
  • Resizable
  • Screen
  • Scroll Area
  • Select
  • Separator
  • Sheet
  • Sidebar
  • Signature Pad
  • Skeleton
  • Slider
  • Spinner
  • Switch
  • Tab Bar
  • Table
  • Tabs
  • Text
  • Textarea
  • Toast
  • Toggle
  • Toggle Group
  • Tooltip
  • Trace
  • Wheel Picker
  • Widget

suiss/ui · Component

Alert

A static callout that draws attention to an important message without interrupting the user.

Alert is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.

import { InfoIcon } from "@phosphor-icons/react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export default function AlertDemo() {
  return (
    <Alert className="w-96">
      <InfoIcon />
      <AlertTitle>Update available</AlertTitle>
      <AlertDescription>
        A new version is ready to install. Restart the app to apply it.
      </AlertDescription>
    </Alert>
  )
}

An Alert is a rounded container with an optional leading icon, an AlertTitle, an optional AlertDescription and an optional AlertAction. Place the icon as a direct child; the layout switches to a two-column grid so the title and description align beside it.

Use an alert for inline, persistent messages such as updates, warnings or errors. To interrupt the user and require a decision, use Alert Dialog instead; for short-lived notifications, use Toast.

Installation

$ pnpm dlx shadcn@latest add @esuiss/alert

Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add alert
  1. Install the following dependencies and add the cn helper:
$ pnpm add class-variance-authority
  1. Copy and paste the following code into your project.
components/ui/alert.tsx
import { cva, type VariantProps } from "class-variance-authority"
import type * as React from "react"
import { cn } from "@/lib/utils"

const alertVariants = cva(
  "w-full grid gap-0.5 rounded-2xl p-5 text-start text-base has-data-[slot=alert-action]:pe-24 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-3 group/alert relative has-data-[slot=alert-description]:*:[svg]:row-span-2 *:[svg]:translate-y-px *:[svg:not([class*='size-'])]:size-5",
  {
    variants: {
      variant: {
        default: "bg-muted text-foreground *:[svg]:text-primary",
        destructive: "bg-muted text-foreground *:[svg]:text-destructive",
      },
    },
    defaultVariants: {
      variant: "default",
    },
  1. Update the import paths to match your project setup.

Usage

import {
  Alert,
  AlertAction,
  AlertDescription,
  AlertTitle,
} from "@/components/ui/alert"
<div className="w-96">
  <Alert>
    <InfoIcon weight="fill" />
    <AlertTitle>Update available</AlertTitle>
    <AlertDescription>
      A new version is ready to install. Restart the app to apply it.
    </AlertDescription>
  </Alert>
</div>

Composition

Use the following composition to build a Alert:

Alert
├── AlertTitle
├── AlertDescription
└── AlertAction

Examples

Destructive

Set variant="destructive" to tint the icon with the destructive color for errors.

import { WarningCircleIcon } from "@phosphor-icons/react"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export default function AlertDestructive() {
  return (
    <Alert className="w-96" variant="destructive">
      <WarningCircleIcon />
      <AlertTitle>Payment failed</AlertTitle>
      <AlertDescription>
        Your card was declined. Update your billing details to continue.
      </AlertDescription>
    </Alert>
  )
}

Without icon

Leave out the icon for a title and description only.

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export default function AlertWithoutIcon() {
  return (
    <Alert className="w-96">
      <AlertTitle>Scheduled maintenance</AlertTitle>
      <AlertDescription>
        The service will be unavailable on Sunday from 2:00 to 4:00 AM.
      </AlertDescription>
    </Alert>
  )
}

Title only

Leave out AlertDescription for an icon with a single line of text.

import { InfoIcon } from "@phosphor-icons/react"
import { Alert, AlertTitle } from "@/components/ui/alert"

export default function AlertTitleOnly() {
  return (
    <Alert className="w-96">
      <InfoIcon />
      <AlertTitle>Your changes have been saved.</AlertTitle>
    </Alert>
  )
}

With action

Put a small button in an AlertAction to place it in the top-end corner.

import { InfoIcon } from "@phosphor-icons/react"
import {
  Alert,
  AlertAction,
  AlertDescription,
  AlertTitle,
} from "@/components/ui/alert"
import { Button } from "@/components/ui/button"

export default function AlertWithAction() {
  return (
    <Alert className="w-96">
      <InfoIcon />
      <AlertTitle>Storage almost full</AlertTitle>
      <AlertDescription>
        You have used 90% of your storage. Upgrade for more space.

Accessibility

  • Alert renders with role="alert", so assistive technology announces its content when it appears.
  • Interactive content in AlertAction stays in the normal tab order.
  • Decorative icons should not need a label; put the meaning in the title text.

API Reference

Alert

The container that lays out the icon, text and action.

PropTypeDefault
variant"default" | "destructive""default"

Also accepts the props of React.ComponentProps<"div">.

Put an icon from your icon library, or any svg, first inside Alert; it is sized to size-5 unless it already has a size class. When AlertDescription is present the icon spans both rows. Both variants use bg-muted and differ only in icon color: default uses text-primary and destructive uses text-destructive. Links inside the title or description are underlined automatically.

AlertTitle

The bold headline of the message.

Also accepts the props of React.ComponentProps<"div">.

AlertDescription

Secondary text that explains the message.

Also accepts the props of React.ComponentProps<"div">.

AlertAction

An absolutely positioned slot for a button or link in the top-end corner.

Also accepts the props of React.ComponentProps<"div">.

The alert reserves end padding for the action automatically. Each part sets a data-slot, such as alert-title or alert-action, for styling.

Web

Web preview

import { CheckCircleIcon } from "phosphor-react-native"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export default function AlertDemo() {
  return (
    <Alert icon={CheckCircleIcon}>
      <AlertTitle>Payment successful</AlertTitle>
      <AlertDescription>
        Your payment of $29.99 has been processed. A receipt has been sent to
        your email.
      </AlertDescription>
    </Alert>
  )
}
import PhosphorSwift
import SwiftUI

struct AlertExample: View {
  var body: some View {
    InlineAlert(icon: Ph.checkCircle.regular) {
      AlertTitle("Payment successful")
      AlertDescription("Your payment of $29.99 has been processed. A receipt has been sent to your email.")
    }
  }
}
import androidx.compose.runtime.Composable
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.CheckCircle
import com.esuiss.ui.components.Alert
import com.esuiss.ui.components.AlertDescription
import com.esuiss.ui.components.AlertTitle

@Composable
fun AlertDefault() {
    Alert(icon = PhosphorIcons.Regular.CheckCircle) {
        AlertTitle("Payment successful")
        AlertDescription("Your payment of \$29.99 has been processed. A receipt has been sent to your email.")
    }
}

Alert is a View on a rounded bg-muted surface with an optional leading icon, a title and description column, and an optional action pinned to the top-end corner. It is static and stays in the layout; it is not a toast or a modal.

Use the default variant for neutral information, where the icon uses the primary color, and destructive for errors, where the icon uses the destructive color.

Installation

$ pnpm dlx shadcn@latest add @esuiss/alert

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add alert
$ pnpm dlx shadcn@latest add @esuiss/alert

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add alert --platform swift
$ pnpm dlx shadcn@latest add @esuiss/alert

See Installation for the components.json setup. Or use the suiss/ui CLI:

$ pnpm dlx @esuiss/ui@latest add alert --platform kotlin

The CLI also adds what it builds on: Icon, Text.

  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Icon, Text.

  2. Copy and paste the following code into components/ui/alert.tsx:

uniwind/components/ui/alert.tsx
import { cn } from "cn"
import type { Icon as PhosphorIcon } from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import { Icon } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"

function Alert({
  className,
  variant = "default",
  children,
  icon,
  iconClassName,
  ...props
}: React.ComponentProps<typeof View> &
  React.RefAttributes<React.ComponentRef<typeof View>> & {
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install cn phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Icon, Text.

  2. Copy and paste the following code into components/ui/alert.tsx:

nativewind/components/ui/alert.tsx
import { cn } from "cn"
import type { Icon as PhosphorIcon } from "phosphor-react-native"
import * as React from "react"
import { View } from "react-native"
import { Icon } from "@/components/ui/icon"
import { Text, TextClassContext } from "@/components/ui/text"

function Alert({
  className,
  variant = "default",
  children,
  icon,
  iconClassName,
  ...props
}: React.ComponentProps<typeof View> &
  React.RefAttributes<React.ComponentRef<typeof View>> & {
  1. Update the import paths to match your project setup.
  1. Install the following dependencies:
npx expo install phosphor-react-native react-native-svg
  1. Add the pieces it builds on: Icon, Text.

  2. Copy and paste the following code into components/ui/alert.tsx:

stylesheet/components/ui/alert.tsx
import type {
  Icon as PhosphorIcon,
  IconProps as PhosphorIconProps,
} from "phosphor-react-native"
import * as React from "react"
import { StyleSheet, View } from "react-native"
import { Icon } from "@/components/ui/icon"
import { Text, TextStyleContext } from "@/components/ui/text"
import { fontSize, metrics, useTheme } from "@/components/ui/theme"

const styles = StyleSheet.create({
  root: {
    position: "relative",
    width: "100%",
    flexDirection: "row",
    gap: 12,
  1. Update the import paths to match your project setup.
  1. Target iOS 17 or later.

  2. Add the Swift package to your app:

Package.swift
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")
  1. Copy the theme files every view uses:
swift/Theme/Theme.swift
import CoreText
import SwiftUI
import UIKit

struct RGBA: Sendable {
  let red: CGFloat
  let green: CGFloat
  let blue: CGFloat
  let alpha: CGFloat

  init(_ hex: UInt32, _ alpha: CGFloat = 1) {
    red = CGFloat((hex >> 16) & 0xFF) / 255
    green = CGFloat((hex >> 8) & 0xFF) / 255
    blue = CGFloat(hex & 0xFF) / 255
    self.alpha = alpha
  }
swift/Theme/Tokens.swift
import SwiftUI

public enum EsuissColor {
  public static let background = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
  public static let foreground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let card = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let cardForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let popover = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
  public static let popoverForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let primary = Color.adaptive(light: .init(0x0071E3), dark: .init(0x0A84FF))
  public static let primaryForeground = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0xFFFFFF))
  public static let secondary = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
  public static let secondaryForeground = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
  public static let muted = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
  public static let mutedForeground = Color.adaptive(light: .init(0x6E6E73), dark: .init(0x86868B))
  public static let accent = Color.adaptive(light: .init(0x000000, 0.06), dark: .init(0xFFFFFF, 0.1))
  1. Copy the source:
swift/Components/Alert.swift
import SwiftUI

public struct InlineAlert<Content: View, Action: View>: View {
  public enum Variant: CaseIterable, Sendable {
    case `default`, destructive
  }

  let variant: Variant
  let icon: Image?
  let content: Content
  let action: Action

  @ScaledMetric(relativeTo: .body) private var iconSize: CGFloat = 20

  public init(
    _ variant: Variant = .default,
  1. Add the files to your app target.
  1. Apply the Compose compiler plugin, enable Compose, set compileSdk to 37 or higher and minSdk to 24 or higher, and add the dependencies:
build.gradle.kts
plugins {
    id("org.jetbrains.kotlin.plugin.compose")
}

android {
    compileSdk = 37
    defaultConfig { minSdk = 24 }
    buildFeatures { compose = true }
}

dependencies {
    implementation(platform("androidx.compose:compose-bom:2026.09.00"))
    implementation("androidx.compose.foundation:foundation")
    implementation("androidx.compose.ui:ui")
    implementation("com.adamglin:phosphor-icon-android:1.0.0")
}
  1. Copy the theme files every view uses:
kotlin/theme/Theme.kt
package com.esuiss.ui.theme

import android.content.res.AssetManager
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.Immutable
import androidx.compose.runtime.staticCompositionLocalOf
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.dropShadow
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.shadow.Shadow as DropShadow
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
kotlin/theme/Tokens.kt
package com.esuiss.ui.theme

import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp

@Immutable
data class Colors(
    val background: Color,
    val foreground: Color,
    val card: Color,
    val cardForeground: Color,
    val popover: Color,
    val popoverForeground: Color,
    val primary: Color,
  1. Copy the source and every file it uses:
kotlin/components/Alert.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
kotlin/components/Content.kt
package com.esuiss.ui.components

import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp

val LocalContentStyle = compositionLocalOf { TextStyle.Default }

val LocalContentColor = compositionLocalOf { Color.Unspecified }

val LocalIconSize = compositionLocalOf { 20.dp }
kotlin/components/Icon.kt
package com.esuiss.ui.components

import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.size
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.takeOrElse
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.Dp
import com.esuiss.ui.theme.EsuissTheme

@Composable
fun Icon(
    imageVector: ImageVector,
kotlin/components/Text.kt
package com.esuiss.ui.components

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.semantics.heading
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.AnnotatedString
  1. Update the com.esuiss.ui package names to match your project.

Usage

import { CheckCircleIcon } from "phosphor-react-native"
import { Alert, AlertTitle, AlertDescription, AlertAction } from "@/components/ui/alert"
<Alert icon={CheckCircleIcon}>
  <AlertTitle>Payment successful</AlertTitle>
  <AlertDescription>
    Your payment of $29.99 has been processed. A receipt has been sent to
    your email.
  </AlertDescription>
</Alert>
import PhosphorSwift
import SwiftUI

struct AlertExample: View {
  var body: some View {
    InlineAlert(icon: Ph.checkCircle.regular) {
      AlertTitle("Payment successful")
      AlertDescription("Your payment of $29.99 has been processed. A receipt has been sent to your email.")
    }
  }
}
import androidx.compose.runtime.Composable
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.CheckCircle
import com.esuiss.ui.components.Alert
import com.esuiss.ui.components.AlertDescription
import com.esuiss.ui.components.AlertTitle

@Composable
fun AlertDefault() {
    Alert(icon = PhosphorIcons.Regular.CheckCircle) {
        AlertTitle("Payment successful")
        AlertDescription("Your payment of \$29.99 has been processed. A receipt has been sent to your email.")
    }
}

Examples

Destructive

Set variant to destructive to color the icon with the destructive color.

Web

Web preview

import { WarningIcon } from "phosphor-react-native"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export default function AlertDestructive() {
  return (
    <Alert icon={WarningIcon} variant="destructive">
      <AlertTitle>Unable to process payment</AlertTitle>
      <AlertDescription>
        Please verify your billing information and try again.
      </AlertDescription>
    </Alert>
  )
}
import PhosphorSwift
import SwiftUI

struct AlertDestructiveExample: View {
  var body: some View {
    InlineAlert(.destructive, icon: Ph.warning.regular) {
      AlertTitle("Unable to process payment")
      AlertDescription("Please verify your billing information and try again.")
    }
  }
}
import androidx.compose.runtime.Composable
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.Warning
import com.esuiss.ui.components.Alert
import com.esuiss.ui.components.AlertDescription
import com.esuiss.ui.components.AlertTitle
import com.esuiss.ui.components.AlertVariant

@Composable
fun AlertDestructive() {
    Alert(icon = PhosphorIcons.Regular.Warning, variant = AlertVariant.Destructive) {
        AlertTitle("Unable to process payment")
        AlertDescription("Please verify your billing information and try again.")
    }
}

Title only

Leave out the description for an alert with only a title.

Web

Web preview

import { InfoIcon } from "phosphor-react-native"
import { Alert, AlertTitle } from "@/components/ui/alert"

export default function AlertTitleOnly() {
  return (
    <Alert icon={InfoIcon}>
      <AlertTitle>Your session will expire in 5 minutes.</AlertTitle>
    </Alert>
  )
}
import PhosphorSwift
import SwiftUI

struct AlertTitleOnlyExample: View {
  var body: some View {
    InlineAlert(icon: Ph.info.regular) {
      AlertTitle("Your session will expire in 5 minutes.")
    }
  }
}
import androidx.compose.runtime.Composable
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.Info
import com.esuiss.ui.components.Alert
import com.esuiss.ui.components.AlertTitle

@Composable
fun AlertTitleOnly() {
    Alert(icon = PhosphorIcons.Regular.Info) {
        AlertTitle("Your session will expire in 5 minutes.")
    }
}

With action

Put a button in an AlertAction to pin it to the top-end corner.

Web

Web preview

import { InfoIcon } from "phosphor-react-native"
import {
  Alert,
  AlertAction,
  AlertDescription,
  AlertTitle,
} from "@/components/ui/alert"
import { Button } from "@/components/ui/button"
import { Text } from "@/components/ui/text"

export default function AlertWithAction() {
  return (
    <Alert icon={InfoIcon}>
      <AlertTitle>New version available</AlertTitle>
      <AlertDescription>
        Update now to get the latest features and fixes.
import PhosphorSwift
import SwiftUI

struct AlertWithActionExample: View {
  var body: some View {
    InlineAlert(icon: Ph.info.regular) {
      AlertTitle("New version available")
      AlertDescription("Update now to get the latest features and fixes.")
    } action: {
      Button("Update") {}
        .buttonStyle(.variant(.tinted, size: .sm))
    }
  }
}
import androidx.compose.runtime.Composable
import com.adamglin.PhosphorIcons
import com.adamglin.phosphoricons.Regular
import com.adamglin.phosphoricons.regular.Info
import com.esuiss.ui.components.Alert
import com.esuiss.ui.components.AlertDescription
import com.esuiss.ui.components.AlertTitle
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonSize
import com.esuiss.ui.components.ButtonVariant

@Composable
fun AlertWithAction() {
    Alert(
        icon = PhosphorIcons.Regular.Info,
        action = { Button("Update", onClick = {}, size = ButtonSize.Sm, variant = ButtonVariant.Tinted) },

Without icon

Leave out the icon for an alert with text only.

Web

Web preview

import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"

export default function AlertWithoutIcon() {
  return (
    <Alert>
      <AlertTitle>Heads up</AlertTitle>
      <AlertDescription>
        You can add components to your app using the registry.
      </AlertDescription>
    </Alert>
  )
}
import SwiftUI

struct AlertWithoutIconExample: View {
  var body: some View {
    InlineAlert {
      AlertTitle("Heads up")
      AlertDescription("You can add components to your app using the registry.")
    }
  }
}
import androidx.compose.runtime.Composable
import com.esuiss.ui.components.Alert
import com.esuiss.ui.components.AlertDescription
import com.esuiss.ui.components.AlertTitle

@Composable
fun AlertWithoutIcon() {
    Alert {
        AlertTitle("Heads up")
        AlertDescription("You can add components to your app using the registry.")
    }
}

Accessibility

  • The container has the alert role.
  • The icon is decorative; put the meaning in the title or description.

API Reference

Alert

Container with the icon, text column and action.

PropTypeDefault
iconPhosphorIcon-
variant"default" | "destructive""default"
iconClassNamestring-

Also accepts the props of React.ComponentProps<typeof View>, React.RefAttributes<View>.

Pass a Phosphor icon component to icon to show it before the text, and use iconClassName to adjust its size or color. variant changes the icon color. Compose AlertTitle and AlertDescription as children.

AlertTitle

Bold first line.

Also accepts the props of React.ComponentProps<typeof Text>.

AlertDescription

Secondary-colored supporting text.

Also accepts the props of React.ComponentProps<typeof Text>.

AlertAction

Slot positioned in the top-end corner.

Also accepts the props of React.ComponentProps<typeof View>, React.RefAttributes<View>.

Any AlertAction child is detected and placed in the corner, and extra end padding is added so the text does not run under it. The action is positioned with end-4, so it flips in right-to-left layouts.

InlineAlert

ParameterTypeDefault
_ variantVariant: .default | .destructive.default
iconImage?nil
content() -> Content-
action() -> Action-

Overloads: init(_:icon:content:action:), init(_:icon:content:).

AlertTitle

Bold first line.

ParameterTypeDefault
_ titleLocalizedStringKey-

AlertDescription

Secondary-colored supporting text.

ParameterTypeDefault
_ descriptionLocalizedStringKey-

AlertVariant

Values: Default, Destructive.

Alert

Container with the icon, text column and action.

ParameterTypeDefault
modifierModifierModifier
variantAlertVariant: Default | DestructiveAlertVariant.Default
iconImageVector?null
action(@Composable () -> Unit)?null
content@Composable ColumnScope.() -> Unit-

AlertTitle

Bold first line.

ParameterTypeDefault
textString-
modifierModifierModifier

AlertDescription

Secondary-colored supporting text.

ParameterTypeDefault
textString-
modifierModifierModifier
NextAlert DialogPreviousAccordion

On this page

  1. 01Installation
  2. 02Usage
  3. 03Composition
  4. 04Examples
    • Destructive
    • Without icon
    • Title only
    • With action
  5. 05Accessibility
  6. 06API Reference
    • Alert
    • AlertTitle
    • AlertDescription
    • AlertAction
  7. 07Installation
  8. 08Usage
  9. 09Examples
    • Destructive
    • Title only
    • With action
    • Without icon
  10. 10Accessibility
  11. 11API Reference
    • Alert
    • AlertTitle
    • AlertDescription
    • AlertAction
    • InlineAlert
    • AlertTitle
    • AlertDescription
    • AlertVariant
    • Alert
    • AlertTitle
    • AlertDescription