Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. iOS
  3. TextAttributes

TextAttributes

MITSwift

A Swift library that simplifies composing attributed strings with strongly typed, chainable APIs.

GitHubGitHub
2.2k stars119 forks0 contributors

What is TextAttributes?

TextAttributes is a Swift library that simplifies the creation and manipulation of attributed strings for iOS and macOS apps. It replaces the cumbersome dictionary-based API of `NSAttributedString` with a type-safe, chainable interface, making text styling more intuitive and less error-prone. It solves the problem of verbose and hard-to-maintain attributed string code by providing a clean, Swift-native abstraction.

Target Audience

iOS and macOS developers who need to style text in their applications, particularly those working with complex typography, dynamic labels, or rich text interfaces.

Value Proposition

Developers choose TextAttributes because it dramatically reduces boilerplate, ensures compile-time safety through strong typing, and offers a fluent API that improves code readability and maintainability compared to Apple's native attributed string APIs.

Overview

An easier way to compose attributed strings

Use Cases

Best For

  • Styling dynamic labels with multiple font and color attributes
  • Building rich text editors or text-heavy interfaces
  • Applying complex paragraph styles like line spacing and alignment
  • Creating reusable text styling components in Swift
  • Improving autocompletion and reducing errors in attributed string code
  • Migrating from Objective-C style dictionaries to Swift-native APIs

Not Ideal For

  • Projects built entirely with SwiftUI, as TextAttributes relies on UIKit/AppKit's NSAttributedString and lacks native SwiftUI integration.
  • Applications with very simple text styling needs where the native API's verbosity is manageable and adding a dependency isn't justified.
  • Teams requiring cross-platform support beyond iOS and macOS, such as for tvOS, watchOS, or frameworks like Flutter.
  • Developers who prioritize using only Apple's latest, actively maintained APIs and avoid third-party dependencies for core functionality.

Pros & Cons

Pros

Type-Safe API

Uses Swift types like UIFont and UIColor instead of raw dictionaries, ensuring compile-time safety and reducing runtime errors, as detailed in the property references.

Fluent Interface

Chainable setter methods allow concise configuration, such as `.font(name:size:).foregroundColor(_:)`, making code more readable and maintainable.

Direct Paragraph Access

Provides direct properties and methods for NSParagraphStyle attributes like alignment and line spacing, simplifying complex text layouts without manual style object creation.

Enhanced Autocompletion

Leverages Swift's type system to offer superior IDE autocompletion compared to string-based keys, speeding up development and reducing typos.

Cons

Platform Lock-in

Only supports iOS and macOS; it's unsuitable for projects targeting other Apple platforms like tvOS or watchOS without additional work, limiting its versatility.

No SwiftUI Support

Lacks built-in integration with SwiftUI, requiring bridging code via UIViewRepresentable, which adds complexity for modern Apple ecosystem development.

Maintenance Concerns

The library's last update was in 2019, as per the license, indicating potential inactivity and reduced support for newer Swift versions or iOS updates.

Abstraction Overhead

Adds a layer over NSAttributedString that, while convenient, might obscure access to low-level APIs or introduce minor performance overhead in edge cases.

Frequently Asked Questions

Quick Stats

Stars2,187
Forks119
Contributors0
Open Issues2
Last commit6 years ago
CreatedSince 2016

Tags

#ios#text-styling#type-safe#ui-development#attributed-strings#cocoapods#swift#carthage#macos

Built With

S
Swift

Included in

iOS51.7kSwift26.0k
Auto-fetched 23 hours ago

Related Projects

YYTextYYText

Powerful text framework for iOS to display and edit rich text.

Stars8,877
Forks1,799
Last commit1 year ago
PhoneNumberKitPhoneNumberKit

A Swift framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber.

Stars5,368
Forks854
Last commit10 days ago
ZSSRichTextEditorZSSRichTextEditor

A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view

Stars3,785
Forks590
Last commit4 years ago
BonMotBonMot

Beautiful, easy attributed strings in Swift

Stars3,561
Forks196
Last commit1 year ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub