Feedback/DSAlert
DSAlert
feedbackInline alert banner with an icon, title, optional message, and a dismiss button. Non-modal.
iOS 17+macOS 14+
Purpose
Contextual feedback inside forms or sections, without interrupting the full screen.
Variants
Info
.info
Neutral information. Blue tint.
Success
.success
Action confirmed. Green tint.
Warning
.warning
Requires attention. Yellow tint.
Error
.error
Failure or validation error. Red tint.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| titlereq | String | — | Alert heading. |
| message | String? | nil | Optional body text. |
| style | DSToastStyle | .info | Semantic style. |
| isDismissable | Bool | true | Shows a close button. |
Examples
Form validation banner
Error alert shown when form submission fails.
swift
if viewModel.hasError {
DSAlert(
title: "Submission failed",
message: viewModel.errorMessage,
style: .error
)
}Success confirmation
Persistent success message in a form.
swift
VStack(alignment: .leading, spacing: DSSpacing.md) {
if formSubmitted {
DSAlert(
title: "Form submitted successfully",
message: "We'll review your application and get back to you within 48 hours.",
style: .success
)
}
// Form fields...
}Composition: Warning with action
Alert with inline action button.
swift
DSAlert(
title: "Storage almost full",
message: "You're using 95% of your storage. Upgrade to get more space.",
style: .warning,
isDismissable: false
)
DSButton("Upgrade Now", variant: .primary) {
showUpgradeModal = true
}When to Use
✓ Use DSAlert for:
- • Form validation errors that need to stay visible
- • Contextual warnings within a specific section
- • Success confirmations that don't auto-dismiss
- • Informational banners with longer text
✗ Avoid using for:
- • Quick confirmations that auto-dismiss (use DSToast)
- • Critical errors blocking the entire app (use DSModal)
- • Persistent app-wide announcements (use DSNoticeBar)
- • Subtle contextual hints (use DSTidbit)
Consider instead:
DSToast
For auto-dismissing confirmations
DSModal
For critical errors requiring explicit action
DSNoticeBar
For app-wide persistent banners
DSTidbit
For subtle inline hints
Accessibility
VoiceOver
Announces title, message, and style (e.g., 'Error: Submission failed')
Keyboard
- • Escape to dismiss (if isDismissable)
- • Tab to close button
Dynamic Type
✓ Supported
Contrast
WCAG AA compliant (background 3:1, text 4.5:1)
Traits
.isAlertRole announced as 'Alert'Immediate announcement when shown