https://github.com/harflabs/MarqueeText
Smooth horizontal scrolling text for SwiftUI
https://github.com/harflabs/MarqueeText
ios macos swift swiftui tvos view visionos
Last synced: 7 days ago
JSON representation
Smooth horizontal scrolling text for SwiftUI
- Host: GitHub
- URL: https://github.com/harflabs/MarqueeText
- Owner: harflabs
- License: mit
- Created: 2025-10-01T12:07:42.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2026-04-28T19:34:52.000Z (2 months ago)
- Last Synced: 2026-04-28T21:25:32.761Z (2 months ago)
- Topics: ios, macos, swift, swiftui, tvos, view, visionos
- Language: Swift
- Homepage: https://harflabs.com
- Size: 10.8 MB
- Stars: 8
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-swift - MarqueeText - Lightweight SwiftUI marquee text component that auto-scrolls only when content overflows. (UI and SwiftUI)
README
# MarqueeText
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.
## Features
- 🎯 **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** - Supports `LocalizedStringResource` and right-to-left layouts
- 📱 **Multi-Platform** - iOS, macOS, tvOS, and visionOS
## Requirements
- iOS 16.0+
- macOS 13.0+
- tvOS 16.0+
- visionOS 1.0+
## Installation
### Swift Package Manager
Add the following to your `Package.swift` file:
```swift
dependencies: [
.package(url: "https://github.com/harflabs/MarqueeText.git", from: "1.1.0")
]
```
Or add it through Xcode:
1. File → Add Package Dependencies
2. Enter the repository URL
3. Select version and add to your target
## Usage
### Basic Usage
```swift
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:
```swift
let title = "Now Playing: Bohemian Rhapsody - Queen"
MarqueeText(title)
MarqueeText(verbatim: title)
```
### Layout Behavior
`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.
### Custom Timing
```swift
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.
### With Styling
```swift
MarqueeText("Styled marquee text")
.font(.headline)
.fontWeight(.semibold)
.foregroundStyle(.primary)
.padding()
.background(
RoundedRectangle(cornerRadius: 12)
.fill(.ultraThinMaterial)
)
```
### Accessibility
`MarqueeText` exposes a single accessibility label for the full text. When Reduce Motion is enabled, overflowing
text is shown without the continuous marquee animation.
## Testing
Run the regression suite with:
```bash
swift test --enable-code-coverage
```
The test suite covers overflow detection, text and layout updates, right-to-left layout, Reduce Motion, invalid sizing
inputs, and redraw-heavy animation timing.
## Examples
### Main Showcase

### Music Player Style

### News Ticker Style

### Short Text (Static)

### Custom Timing

### Status Bar Style

### Social Media Feed

### Notification Banner

### Loading Screen

### Terminal/Console

## Apps Using MarqueeText
- [Casti - Your Personalized Podcasts, Powered by AI](https://apps.apple.com/app/id6746376736)
- [Tilfaz - Live & On-Demand TV](https://apps.apple.com/app/id1668359578)
*Add your app here! Submit a pull request to include your app.*
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## About Harf Labs
This library is built by [Harf Labs](https://harflabs.com), 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](https://harflabs.com/en/contact) and let's build something amazing together.