suiss/uim · React Native Component
Alert Sheet
A sheet that slides up from the bottom with a short list of actions and a separate cancel button.
Alert Sheet is an open-source mobile component from suiss/uim for React Native and Expo, with SwiftUI and Jetpack Compose versions built from the same design tokens. The @esuiss/uim CLI copies its source into your project, so you own the code.


import { View } from "react-native"
import { AlertSheet, AlertSheetAction, AlertSheetCancel, AlertSheetContent, AlertSheetDescription, AlertSheetGroup, AlertSheetHeader, AlertSheetTitle, AlertSheetTrigger } from "@/components/ui/alert-sheet"
import { Button } from "@/components/ui/button"
import { Text } from "@/components/ui/text"
function SheetBody() {
return (
<AlertSheetContent>
<AlertSheetGroup>
<AlertSheetHeader>
<AlertSheetTitle>Delete this photo?</AlertSheetTitle>
<AlertSheetDescription>
This photo will be deleted from all of your devices.
</AlertSheetDescription>
</AlertSheetHeader>
<AlertSheetAction>Save to Files</AlertSheetAction>
<AlertSheetAction variant="destructive">Delete Photo</AlertSheetAction>
</AlertSheetGroup>
<AlertSheetCancel>Cancel</AlertSheetCancel>
</AlertSheetContent>
)
}
export function AlertSheetOpenByDefaultExample() {
return (
<View className="items-start">
<AlertSheet defaultOpen>
<AlertSheetTrigger render={<Button variant="outline" />}>
<Text>Show sheet</Text>
</AlertSheetTrigger>
<SheetBody />
</AlertSheet>
</View>
)
}import EsuissUI
import SwiftUI
struct AlertSheetOpenByDefaultExample: View {
var body: some View {
AlertSheetDemo(title: "Show sheet", open: true) {
AlertSheetBody()
}
}
}
struct AlertSheetDemo<Body: View>: View {
let title: LocalizedStringKey
let dismissible: Bool
let content: () -> Body
@State private var open: Bool
init(
title: LocalizedStringKey,
open: Bool = false,
dismissible: Bool = true,
@ViewBuilder content: @escaping () -> Body
) {
self.title = title
self.dismissible = dismissible
self.content = content
_open = State(initialValue: open)
}
var body: some View {
Button(title) { open = true }
.buttonStyle(.variant(.outline))
.alertSheet(isPresented: $open, dismissible: dismissible, content: content)
}
}
struct AlertSheetBody: View {
var body: some View {
AlertSheetContent {
AlertSheetGroup {
AlertSheetHeader {
AlertSheetTitle("Delete this photo?")
AlertSheetDescription("This photo will be deleted from all of your devices.")
}
AlertSheetAction("Save to Files")
AlertSheetAction("Delete Photo", variant: .destructive)
}
AlertSheetCancel("Cancel")
}
}
}import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.esuiss.ui.components.AlertSheet
import com.esuiss.ui.components.AlertSheetAction
import com.esuiss.ui.components.AlertSheetActionVariant
import com.esuiss.ui.components.AlertSheetCancel
import com.esuiss.ui.components.AlertSheetDescription
import com.esuiss.ui.components.AlertSheetGroup
import com.esuiss.ui.components.AlertSheetHeader
import com.esuiss.ui.components.AlertSheetTitle
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonVariant
@Composable
fun AlertSheetOpenByDefaultExample() {
AlertSheetDefault(defaultOpen = true)
}
@Composable
fun AlertSheetDefault(defaultOpen: Boolean) {
var open by rememberSaveable { mutableStateOf(defaultOpen) }
Column {
Button("Show sheet", onClick = { open = true }, variant = ButtonVariant.Outline)
AlertSheet(open = open, onOpenChange = { open = it }) {
AlertSheetGroup {
AlertSheetHeader {
AlertSheetTitle("Delete this photo?")
AlertSheetDescription("This photo will be deleted from all of your devices.")
}
AlertSheetAction("Save to Files", onClick = {})
AlertSheetAction("Delete Photo", onClick = {}, variant = AlertSheetActionVariant.Destructive)
}
AlertSheetCancel("Cancel")
}
}
}AlertSheet presents a set of choices related to the current context. AlertSheetContent renders through a portal (inside a full-window overlay on iOS), slides up from the bottom over a dimmed scrim, and respects the safe-area insets.
Actions sit in an AlertSheetGroup, a rounded card that draws a hairline between each child, and AlertSheetCancel sits below it as its own card with bold text. Use it for two to a few actions; for a single decision that needs confirmation, use Alert Dialog.
Installation
$ pnpm dlx @esuiss/uim@latest add alert-sheet$ pnpm dlx @esuiss/uim@latest add alert-sheet --platform swift$ pnpm dlx @esuiss/uim@latest add alert-sheet --platform kotlinThe CLI also adds what it builds on: Icon, Text.
Manual
- Install the dependencies:
npx expo install class-variance-authority cn react-native-reanimated react-native-safe-area-context react-native-screens react-native-worklets-
Add the pieces it builds on: Icon, Text, and the primitives
components/primitives/alert-dialog.tsx,components/primitives/dialog.tsx,components/primitives/use-render.tsx. -
Copy the source into
components/ui/alert-sheet.tsx:
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import * as React from "react"
import { Platform, View, type ViewProps } from "react-native"
import {
Easing,
FadeIn,
FadeOut,
ReduceMotion,
SlideInDown,
SlideOutDown,
} from "react-native-reanimated"
import { useSafeAreaInsets } from "react-native-safe-area-context"
import { FullWindowOverlay as RNFullWindowOverlay } from "react-native-screens"
import * as AlertSheetPrimitive from "@/components/primitives/alert-dialog"
import * as DialogPrimitive from "@/components/primitives/dialog"- Update the import paths to match your project.
- Install the dependencies:
npx expo install class-variance-authority cn react-native-reanimated react-native-safe-area-context react-native-screens react-native-worklets-
Add the pieces it builds on: Icon, Text, and the primitives
components/primitives/alert-dialog.tsx,components/primitives/dialog.tsx,components/primitives/use-render.tsx. -
Copy the source into
components/ui/alert-sheet.tsx:
import { cva, type VariantProps } from "class-variance-authority"
import { cn } from "cn"
import * as React from "react"
import { Platform, View, type ViewProps } from "react-native"
import {
Easing,
FadeIn,
FadeOut,
ReduceMotion,
SlideInDown,
SlideOutDown,
} from "react-native-reanimated"
import { useSafeAreaInsets } from "react-native-safe-area-context"
import { FullWindowOverlay as RNFullWindowOverlay } from "react-native-screens"
import * as AlertSheetPrimitive from "@/components/primitives/alert-dialog"
import * as DialogPrimitive from "@/components/primitives/dialog"- Update the import paths to match your project.
- Install the dependencies:
npx expo install react-native-reanimated react-native-safe-area-context react-native-screens react-native-worklets-
Add the pieces it builds on: Icon, Text, and the primitives
components/primitives/alert-dialog.tsx,components/primitives/dialog.tsx,components/primitives/use-render.tsx. -
Copy the source into
components/ui/alert-sheet.tsx:
import * as React from "react"
import {
Platform,
Pressable,
StyleSheet,
type TextStyle,
View,
type ViewProps,
} from "react-native"
import {
Easing,
FadeIn,
FadeOut,
ReduceMotion,
SlideInDown,
SlideOutDown,- Update the import paths to match your project.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
.package(url: "https://github.com/phosphor-icons/swift", from: "2.1.0")- Copy the theme files every view uses:
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
}import SwiftUI
extension Color {
public static let surface = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))
public static let surfaceSecondary = Color.adaptive(light: .init(0xF5F5F7), dark: .init(0x161617))
public static let surfaceTertiary = Color.adaptive(light: .init(0xE8E8ED), dark: .init(0x2C2C2E))
public static let surfaceRaised = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x1D1D1F))
public static let label = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
public static let labelSecondary = Color.adaptive(light: .init(0x6E6E73), dark: .init(0xA1A1A6))
public static let labelTertiary = Color.adaptive(light: .init(0x86868B), dark: .init(0x86868B))
public static let labelQuaternary = Color.adaptive(light: .init(0xD2D2D7), dark: .init(0x424245))
public static let control = Color.adaptive(light: .init(0x000000, 0.04), dark: .init(0xFFFFFF, 0.1))
public static let controlPressed = Color.adaptive(light: .init(0x000000, 0.12), dark: .init(0xFFFFFF, 0.22))
public static let controlSelected = Color.adaptive(light: .init(0x1D1D1F), dark: .init(0xF5F5F7))
public static let controlDisabled = Color.adaptive(light: .init(0x000000, 0.03), dark: .init(0xFFFFFF, 0.05))
public static let onControlSelected = Color.adaptive(light: .init(0xFFFFFF), dark: .init(0x000000))- Copy the source and every file it uses:
import SwiftUI
extension View {
public func alertSheet<Content: View>(
isPresented: Binding<Bool>,
dismissible: Bool = true,
@ViewBuilder content: @escaping () -> Content
) -> some View {
modifier(
CoverPresenter(
isPresented: isPresented,
enter: .timingCurve(0.32, 0.72, 0, 1, duration: 0.3),
exit: .timingCurve(0.32, 0.72, 0, 1, duration: 0.25)
) { visible in
AlertSheetStage(visible: visible, dismissible: dismissible, content: content)
}import SwiftUI
public struct VariantButtonStyle: ButtonStyle {
public enum Variant: CaseIterable, Sendable {
case `default`, outline, secondary, tinted, ghost, plain, destructive, link
}
public enum Size: CaseIterable, Sendable {
case `default`, xs, sm, lg, xl, icon, iconXs, iconSm, iconLg, iconXl
var height: CGFloat {
switch self {
case .xs, .iconXs: 24
case .sm, .iconSm: 32
case .default, .icon: 36
case .lg, .iconLg: 44import SwiftUI
extension EnvironmentValues {
@Entry var buttonGroup: Axis? = nil
@Entry var buttonGroupSize: CGSize = .zero
}
enum ButtonGroupSpace: Hashable {
case group
}
struct ButtonGroupFrame {
let bounds: Anchor<CGRect>
let outlined: Bool
}import PhosphorSwift
import SwiftUI
extension Shadow {
static let control = Shadow(color: .black.opacity(0.08), radius: 0.5, y: 0.5)
static let thumb = Shadow(color: .black.opacity(0.12), radius: 1.5, y: 1)
}
struct SelectionIndicator<Mark: View>: View {
let checked: Bool
let pressed: Bool
let cornerRadius: CGFloat
let mark: Mark
@Environment(\.isEnabled) private var isEnabled
@Environment(\.isInvalid) private var invalidimport SwiftUI
extension EnvironmentValues {
@Entry public var isInvalid = false
@Entry var fieldInset = false
@Entry var fieldGroupInset = false
@Entry var fieldSetInset = false
}
extension View {
public func invalid(_ isInvalid: Bool = true) -> some View {
environment(\.isInvalid, isInvalid)
}
}
public enum FieldOrientation: CaseIterable, Sendable {import SwiftUI
extension EnvironmentValues {
@Entry public var hapticsEnabled = true
}
extension View {
public func haptics(_ enabled: Bool) -> some View {
environment(\.hapticsEnabled, enabled)
}
func hapticFeedback<Trigger: Equatable>(_ feedback: SensoryFeedback, trigger: Trigger) -> some View {
modifier(HapticFeedbackModifier(feedback: feedback, trigger: trigger) { _, _ in true })
}
func hapticFeedback<Trigger: Equatable>(import PhosphorSwift
import Observation
import SwiftUI
public enum PopupAlignment: Sendable, CaseIterable {
case start, center, end
}
struct OverlayDismiss: Sendable {
let action: @MainActor @Sendable () -> Void
@MainActor func callAsFunction() {
action()
}
}import SwiftUI
public struct Separator: View {
let orientation: Axis
public init(_ orientation: Axis = .horizontal) {
self.orientation = orientation
}
public var body: some View {
Rectangle()
.fill(Color.separator)
.frame(width: orientation == .vertical ? 1 : nil, height: orientation == .horizontal ? 1 : nil)
.frame(maxWidth: orientation == .horizontal ? .infinity : nil, maxHeight: orientation == .vertical ? .infinity : nil)
.accessibilityHidden(true)
}import SwiftUI
public enum TextVariant: CaseIterable, Sendable {
case `default`, h1, h2, h3, h4, p, blockquote, code, lead, large, small, muted
var style: TextStyle {
switch self {
case .h1: .xl3
case .h2: .xl2
case .h3: .xl
case .h4, .lead, .large: .lg
case .code, .small, .muted: .sm
default: .base
}
}- Add the files to your app target.
- Set
minSdkto 24 or higher and add the 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")- Copy the theme files every view uses:
package com.esuiss.ui.theme
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.text.TextStyle
import androidx.compose.ui.text.style.LineHeightStyle
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.DpOffsetpackage com.esuiss.ui.theme
import androidx.compose.runtime.Immutable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
@Immutable
data class Colors(
val surface: Color,
val surfaceSecondary: Color,
val surfaceTertiary: Color,
val surfaceRaised: Color,
val label: Color,
val labelSecondary: Color,
val labelTertiary: Color,
val labelQuaternary: Color,- Copy the source and every file it uses:
package com.esuiss.ui.components
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Boxpackage com.esuiss.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.interaction.collectIsPressedAsState
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShapepackage com.esuiss.ui.components
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.CornerSize
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.Immutablepackage 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 }package com.esuiss.ui.components
import android.provider.Settings
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.text.selection.TextSelectionColors
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawWithContent
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Sizepackage 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,package com.esuiss.ui.components
import android.os.Build
import android.view.Window
import android.view.WindowManager
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.AnimatedVisibilityScope
import androidx.compose.animation.EnterExitState
import androidx.compose.animation.core.MutableTransitionState
import androidx.compose.animation.core.animateFloat
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.scaleIn
import androidx.compose.animation.scaleOut
import androidx.compose.animation.slideIn- Update the
com.esuiss.uipackage names to match your project.
Usage
import { AlertSheet, AlertSheetOverlay, AlertSheetContent, AlertSheetGroup, AlertSheetHeader, AlertSheetTitle, AlertSheetDescription, AlertSheetAction, AlertSheetCancel } from "@/components/ui/alert-sheet"<View className="items-start">
<AlertSheet defaultOpen>
<AlertSheetTrigger render={<Button variant="outline" />}>
<Text>Show sheet</Text>
</AlertSheetTrigger>
<SheetBody />
</AlertSheet>
</View>Compose AlertSheetTrigger and AlertSheetContent. Inside the content, put an AlertSheetGroup with an optional AlertSheetHeader (AlertSheetTitle, AlertSheetDescription) followed by AlertSheetActions, then an AlertSheetCancel.
Every action closes the sheet when pressed. String children are wrapped in Text automatically. Use variant="destructive" on an action that deletes or removes, and disabled to dim and block it.
By default the sheet is dismissible and a tap on the scrim closes it. Set dismissible={false} to require an explicit choice.
Examples
Default


import { View } from "react-native"
import { AlertSheet, AlertSheetAction, AlertSheetCancel, AlertSheetContent, AlertSheetDescription, AlertSheetGroup, AlertSheetHeader, AlertSheetTitle, AlertSheetTrigger } from "@/components/ui/alert-sheet"
import { Button } from "@/components/ui/button"
import { Text } from "@/components/ui/text"
function SheetBody() {
return (
<AlertSheetContent>
<AlertSheetGroup>
<AlertSheetHeader>
<AlertSheetTitle>Delete this photo?</AlertSheetTitle>
<AlertSheetDescription>
This photo will be deleted from all of your devices.
</AlertSheetDescription>
</AlertSheetHeader>
<AlertSheetAction>Save to Files</AlertSheetAction>
<AlertSheetAction variant="destructive">Delete Photo</AlertSheetAction>
</AlertSheetGroup>
<AlertSheetCancel>Cancel</AlertSheetCancel>
</AlertSheetContent>
)
}
export function AlertSheetExample() {
return (
<View className="items-start">
<AlertSheet>
<AlertSheetTrigger render={<Button variant="outline" />}>
<Text>Show sheet</Text>
</AlertSheetTrigger>
<SheetBody />
</AlertSheet>
</View>
)
}import EsuissUI
import SwiftUI
struct AlertSheetExample: View {
var body: some View {
AlertSheetDemo(title: "Show sheet") {
AlertSheetBody()
}
}
}
struct AlertSheetDemo<Body: View>: View {
let title: LocalizedStringKey
let dismissible: Bool
let content: () -> Body
@State private var open: Bool
init(
title: LocalizedStringKey,
open: Bool = false,
dismissible: Bool = true,
@ViewBuilder content: @escaping () -> Body
) {
self.title = title
self.dismissible = dismissible
self.content = content
_open = State(initialValue: open)
}
var body: some View {
Button(title) { open = true }
.buttonStyle(.variant(.outline))
.alertSheet(isPresented: $open, dismissible: dismissible, content: content)
}
}
struct AlertSheetBody: View {
var body: some View {
AlertSheetContent {
AlertSheetGroup {
AlertSheetHeader {
AlertSheetTitle("Delete this photo?")
AlertSheetDescription("This photo will be deleted from all of your devices.")
}
AlertSheetAction("Save to Files")
AlertSheetAction("Delete Photo", variant: .destructive)
}
AlertSheetCancel("Cancel")
}
}
}import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.esuiss.ui.components.AlertSheet
import com.esuiss.ui.components.AlertSheetAction
import com.esuiss.ui.components.AlertSheetActionVariant
import com.esuiss.ui.components.AlertSheetCancel
import com.esuiss.ui.components.AlertSheetDescription
import com.esuiss.ui.components.AlertSheetGroup
import com.esuiss.ui.components.AlertSheetHeader
import com.esuiss.ui.components.AlertSheetTitle
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonVariant
@Composable
fun AlertSheetExample() {
AlertSheetDefault(defaultOpen = false)
}
@Composable
fun AlertSheetDefault(defaultOpen: Boolean) {
var open by rememberSaveable { mutableStateOf(defaultOpen) }
Column {
Button("Show sheet", onClick = { open = true }, variant = ButtonVariant.Outline)
AlertSheet(open = open, onOpenChange = { open = it }) {
AlertSheetGroup {
AlertSheetHeader {
AlertSheetTitle("Delete this photo?")
AlertSheetDescription("This photo will be deleted from all of your devices.")
}
AlertSheetAction("Save to Files", onClick = {})
AlertSheetAction("Delete Photo", onClick = {}, variant = AlertSheetActionVariant.Destructive)
}
AlertSheetCancel("Cancel")
}
}
}Not dismissible
dismissible={false} with a destructive and a disabled action.


import { View } from "react-native"
import { AlertSheet, AlertSheetAction, AlertSheetCancel, AlertSheetContent, AlertSheetGroup, AlertSheetHeader, AlertSheetTitle, AlertSheetTrigger } from "@/components/ui/alert-sheet"
import { Button } from "@/components/ui/button"
import { Text } from "@/components/ui/text"
export function AlertSheetNotDismissibleExample() {
return (
<View className="items-start">
<AlertSheet dismissible={false}>
<AlertSheetTrigger render={<Button variant="outline" />}>
<Text>Sign out</Text>
</AlertSheetTrigger>
<AlertSheetContent>
<AlertSheetGroup>
<AlertSheetHeader>
<AlertSheetTitle>Sign out of all devices?</AlertSheetTitle>
</AlertSheetHeader>
<AlertSheetAction variant="destructive">Sign Out</AlertSheetAction>
<AlertSheetAction disabled>Keep Signed In Here</AlertSheetAction>
</AlertSheetGroup>
<AlertSheetCancel>Cancel</AlertSheetCancel>
</AlertSheetContent>
</AlertSheet>
</View>
)
}import EsuissUI
import SwiftUI
struct AlertSheetNotDismissibleExample: View {
var body: some View {
AlertSheetDemo(title: "Sign out", dismissible: false) {
AlertSheetContent {
AlertSheetGroup {
AlertSheetHeader {
AlertSheetTitle("Sign out of all devices?")
}
AlertSheetAction("Sign Out", variant: .destructive)
AlertSheetAction("Keep Signed In Here")
.disabled(true)
}
AlertSheetCancel("Cancel")
}
}
}
}
struct AlertSheetDemo<Body: View>: View {
let title: LocalizedStringKey
let dismissible: Bool
let content: () -> Body
@State private var open: Bool
init(
title: LocalizedStringKey,
open: Bool = false,
dismissible: Bool = true,
@ViewBuilder content: @escaping () -> Body
) {
self.title = title
self.dismissible = dismissible
self.content = content
_open = State(initialValue: open)
}
var body: some View {
Button(title) { open = true }
.buttonStyle(.variant(.outline))
.alertSheet(isPresented: $open, dismissible: dismissible, content: content)
}
}import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.esuiss.ui.components.AlertSheet
import com.esuiss.ui.components.AlertSheetAction
import com.esuiss.ui.components.AlertSheetActionVariant
import com.esuiss.ui.components.AlertSheetCancel
import com.esuiss.ui.components.AlertSheetGroup
import com.esuiss.ui.components.AlertSheetHeader
import com.esuiss.ui.components.AlertSheetTitle
import com.esuiss.ui.components.Button
import com.esuiss.ui.components.ButtonVariant
@Composable
fun AlertSheetNotDismissible() {
var open by rememberSaveable { mutableStateOf(false) }
Column {
Button("Sign out", onClick = { open = true }, variant = ButtonVariant.Outline)
AlertSheet(open = open, onOpenChange = { open = it }, dismissible = false) {
AlertSheetGroup {
AlertSheetHeader {
AlertSheetTitle("Sign out of all devices?")
}
AlertSheetAction("Sign Out", onClick = {}, variant = AlertSheetActionVariant.Destructive)
AlertSheetAction("Keep Signed In Here", onClick = {}, enabled = false)
}
AlertSheetCancel("Cancel")
}
}
}API Reference
AlertSheet
Root that holds the open state.
AlertSheetPrimitive.RootProps- About
- When
false, the scrim no longer closes the sheet. Defaults totrue. - Type
boolean- Default
- true
AlertSheetOverlay
Dimmed scrim behind the sheet.
React.ComponentProps<typeof AlertSheetPrimitive.Backdrop>AlertSheetContent
Bottom-anchored container that slides in and out.
React.ComponentProps<typeof AlertSheetPrimitive.Popup>- About
- Name of the portal host to render into.
- Type
string- Default
- —
AlertSheetGroup
Rounded card that separates its children with hairlines.
ViewPropsAlertSheetHeader
Centered block for the title and description.
ViewPropsAlertSheetTitle
Small, bold heading for the sheet.
React.ComponentProps<typeof AlertSheetPrimitive.Title>AlertSheetDescription
Supporting text below the title.
React.ComponentProps<typeof AlertSheetPrimitive.Description>AlertSheetAction
Full-width action row that closes the sheet.
AlertSheetActionPropsAlertSheetCancel
Separate cancel card with bold text.
AlertSheetActionPropsAccessibility
- When dismissible the popup has the
dialogrole, otherwisealertdialog; it is labelled by the title and marked as modal for VoiceOver. - Focus moves to the title when the sheet opens.
- Actions have the
buttonrole with adisabledstate. - Separators between actions are hidden from screen readers.
Notes
- Padding uses the bottom and side safe-area insets, with a minimum of 8 points.
- On iOS the content is wrapped in a full-window overlay.
- Animations respect the system Reduce Motion setting.
- Uses
bg-surface-raised,bg-item-pressed,text-linkandtext-dangertokens; light and dark follow the system appearance.