attributed-string

Apply attributes to ranges in Swift AttributedString for rich text formatting.

603|51|Updated Oct 29, 2025
One-click install
npx skills add https://github.com/rshankras/claude-code-apple-skills --skill attributed-string
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: attributed-string
Source: https://github.com/rshankras/claude-code-apple-skills/tree/main/skills/foundation/attributed-string
Command: npx skills add https://github.com/rshankras/claude-code-apple-skills --skill attributed-string

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill simplifies the creation, manipulation, and display of rich text using Swift's AttributedString, ensuring correct styling, alignment, and editing behavior across Apple platforms.

Core Features & Use Cases

  • Rich Text Creation: Generate styled text with fonts, colors, and backgrounds.
  • Attribute Manipulation: Apply attributes to specific ranges within text.
  • Layout Control: Manage text alignment, writing direction, and line height.
  • Text Editing: Programmatically handle text selection and replacement.
  • SwiftUI Integration: Seamlessly use AttributedString in Text and TextEditor.
  • Use Case: Automatically format user-generated comments in an app with specific styles for mentions or hashtags, and enable rich text editing in a TextEditor.

Quick Start

Use the attributed-string skill to create a bold and red attributed string with the text "Hello, World!".

Frequently Asked Questions about attributed-string

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create rich text with custom fonts and colors in Swift?

To create rich text in Swift, use `AttributedString` to generate styled text with custom fonts, colors, and backgrounds applied directly to specific string ranges.

Can I use AttributedString with SwiftUI TextEditor for editing?

Yes, you can use `AttributedString` with SwiftUI integration, enabling rich text editing and programmatic text selection or replacement directly within a `TextEditor` component.

How do I apply text formatting to specific ranges in Swift?

Apply text formatting to specific ranges in Swift by manipulating attributes on an `AttributedString`, targeting discontiguous substrings for precise styling control.

What is the best way to control text alignment and line height in SwiftUI?

Control text alignment, writing direction, and line height in SwiftUI by configuring layout attributes on your `AttributedString` before rendering it in a `Text` view.

How does programmatic text selection work with discontiguous substrings?

Programmatic text selection with discontiguous substrings works by applying attributes or selecting non-contiguous ranges within an `AttributedString`, allowing complex text replacement and editing behavior.

Does this rich text approach handle user-generated mentions and hashtags?

Yes, this approach handles user-generated mentions and hashtags by using `AttributedString` to automatically format specific text ranges with distinct styles like custom fonts and background colors.