StandardActions is a SwiftUI library that defines standard action types, with localized titles, icons, shortcuts, etc.
StandardActions has a StandardActionType enum with 130+ common actions like .add, .remove, etc., as well as a StandardToggleType enum with common values, a StandardAction with common actions, etc.
Each StandardActionType has a localized .title, an .image, a .role, and an optional .keyboardShortcut. These properties will automatically be applied when you create type-based buttons, labels, links, and toggles.
StandardActions can be installed with the Swift Package Manager:
https://github.com/danielsaidi/StandardActions.git
You can become a sponsor to help me dedicate more time on my various open-source tools. Every contribution, no matter the size, makes a real difference in keeping these tools free and actively developed.
You can create Button, Label and Link views for any StandardActionType. This will automatically apply a localized title, icon, etc.
Button(.add) { ... }
Label(.add) { ... }
Link(.email, destination: .email(...))You can create Toggle views for any StandardToggleType and a boolean binding. This automatically applies the localized title, icon, role, shortcut, accessibility, etc. for the provided toggle type, based on the toggle state:
Toggle(.isVisible, isOn: $isVisible)You can use StandardAction to generate a standard control for common actions, like .call(phoneNumber:), .copy(_:), .email(address:), and .openUrl(_:).
/// Render a control for the provided action
StandardActionControl(.email(address: "daniel@gmail.com"))
/// Render a list item with the action as a trailing action
StandardActionListItem(
actoin: .email(address: "daniel@gmail.com"),
title: ...,
text: ...
)You can also use URL extensions like .call(number:) and .email(address:) to generate URLs for common URL-based actions.
This library is localized in the following languages:
- 🇩🇰 Danish
- 🇺🇸 English (US)
- 🇫🇷 French
- 🇬🇪 Georgian
- 🇩🇪 German
- 🇳🇴 Norwegian Bokmål
- 🇪🇸 Spanish
- 🇸🇪 Swedish
You can add more locales to the Localizable.xcstrings file in the Resources folder, then localize them as described in this blog post.
The online documentation has more information, articles, code examples, etc.
This repository will get a demo app after it reaches 100 stars.
Feel free to reach out if you have questions, or want to contribute in any way:
- Website: danielsaidi.com
- E-mail: daniel.saidi@gmail.com
- Bluesky: @danielsaidi@bsky.social
- Mastodon: @danielsaidi@mastodon.social
StandardActions is available under the MIT license. See the LICENSE file for more info.
