A lightweight SwiftUI component that automatically creates marquee scrolling animations when text overflows its container. Perfect for music players, news tickers, status displays, and more.
- 🎯 Automatic Detection - Only scrolls when text overflows
- ⚡️ Smooth Animations - Customizable duration, delay, and spacing
- 🎨 SwiftUI Native - Built with pure SwiftUI
- ♿️ Accessible - VoiceOver-friendly labels with Reduce Motion support
↔️ Localizable - SupportsLocalizedStringResourceand right-to-left layouts- 📱 Multi-Platform - iOS, macOS, tvOS, and visionOS
- iOS 16.0+
- macOS 13.0+
- tvOS 16.0+
- visionOS 1.0+
Add the following to your Package.swift file:
dependencies: [
.package(url: "https://github.com/harflabs/MarqueeText.git", from: "1.1.0")
]Or add it through Xcode:
- File → Add Package Dependencies
- Enter the repository URL
- Select version and add to your target
import MarqueeText
MarqueeText("This is a long text that will scroll smoothly across the screen!")String literals use SwiftUI's localized string resource behavior. For runtime strings, such as titles from an API,
you can pass a String value directly or use the explicit verbatim initializer when you want to make that intent
clear:
let title = "Now Playing: Bohemian Rhapsody - Queen"
MarqueeText(title)
MarqueeText(verbatim: title)MarqueeText measures the rendered text and available width, so short text stays static and overflowing text scrolls.
It remeasures when SwiftUI layout changes, including font, Dynamic Type, locale, and container size updates. This keeps
the marquee responsive in lists, stacks, compact controls, and during device rotation.
Right-to-left layout direction mirrors the marquee alignment and scroll direction.
MarqueeText(
"Custom timing marquee text",
duration: 4.0, // Animation duration
delay: 0.5, // Delay before starting
spacing: 30 // Space between repeated text
)Invalid duration, delay, and spacing values are clamped to safe defaults.
MarqueeText("Styled marquee text")
.font(.headline)
.fontWeight(.semibold)
.foregroundStyle(.primary)
.padding()
.background(
RoundedRectangle(cornerRadius: 12)
.fill(.ultraThinMaterial)
)MarqueeText exposes a single accessibility label for the full text. When Reduce Motion is enabled, overflowing
text is shown without the continuous marquee animation.
Run the regression suite with:
swift test --enable-code-coverageThe test suite covers overflow detection, text and layout updates, right-to-left layout, Reduce Motion, invalid sizing inputs, and redraw-heavy animation timing.
Add your app here! Submit a pull request to include your app.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
This library is built by Harf Labs, a software development company that creates solutions for real problems.
If you like this project and need help with your own software projects, we'd love to hear from you! Get in touch and let's build something amazing together.









