swiftui-async-button

Use ButtonKit's AsyncButton for SwiftUI button actions that start a Task, call async/await, use do/catch, or need built-in loading/progress/error feedback. Trigger when replacing custom Button+Task wrappers or when a button action can throw or is async.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "swiftui-async-button" with this command: npx skills add dean151/buttonkit/dean151-buttonkit-swiftui-async-button

SwiftUI Async Button

Overview

Prefer ButtonKit AsyncButton over custom Button { Task { ... } } or manual do/catch wrappers to get standardized loading, progress, and error feedback for async or throwing actions.

Core workflow

  1. Ensure ButtonKit is imported with import ButtonKit ; and that the dependency to ButtonKit is added to Swift Package Manager dependencies
  2. Replace any Button action that spawns Task { ... } or uses do { try await ... } catch { ... } with AsyncButton { try await ... }.
  3. Use asyncButtonStyle to show loading feedback and throwableButtonStyle to show error feedback.
  4. Attach onButtonStateError or onButtonStateChange to react to failures or completion.
  5. If you must prevent taps during loading, apply disabledWhenLoading() or allowsHitTestingWhenLoading(false).
  6. Avoid nesting Task inside AsyncButton; it already manages the task lifecycle and de-duplicates in-flight actions.

External triggers

When another UI event should trigger the same action (e.g., keyboard submit), assign an id to AsyncButton and use @Environment(\.triggerButton) to trigger it.

Progress

If the action can report progress, use AsyncButton(progress: ...) and update the provided progress object. For supported progress types, styles, and demo patterns, read skills/swiftui-async-button/references/asyncbutton.md.

References

  • skills/swiftui-async-button/references/asyncbutton.md

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

image-gen

Generate AI images from text prompts. Triggers on: "生成图片", "画一张", "AI图", "generate image", "配图", "create picture", "draw", "visualize", "generate an image".

Archived SourceRecently Updated
General

explainer

Create explainer videos with narration and AI-generated visuals. Triggers on: "解说视频", "explainer video", "explain this as a video", "tutorial video", "introduce X (video)", "解释一下XX(视频形式)".

Archived SourceRecently Updated
General

asr

Transcribe audio files to text using local speech recognition. Triggers on: "转录", "transcribe", "语音转文字", "ASR", "识别音频", "把这段音频转成文字".

Archived SourceRecently Updated