ExpandableText 😎 (SwiftUI) Expand the text with the "more" button

Overview

ExpandableText 😎 (SwiftUI)

version Swift: 5.1+ iOS: 13.0+ license

Expand the text with the "more" button

example

Get Started

import SwiftUI
import ExpandableText

struct ExpandableText_Test: View {
    
    var body: some View {
        ExpandableText(text: "Do you think you're living an ordinary life? You are so mistaken it's difficult to even explain. The mere fact that you exist makes you extraordinary. The odds of you existing are less than winning the lottery, but here you are. Are you going to let this extraordinary opportunity pass?")
            .font(.body)//optional
            .foregroundColor(.primary)//optional
            .lineLimit(3)//optional
            .animation(.easeOut)//optional
            .padding(.horizontal, 24)//optional
    }
}

Modifier(optional)

Modifier Default
.font(_ font: Font) .body
.lineLimit(_ lineLimit: Int) 3
.foregroundColor(_ color: Color) .primary
.expandButtonText(_ text: String) "more"
.expandButtonColor(_ color: Color) .blue
You might also like...
Render Markdown text in SwiftUI
Render Markdown text in SwiftUI

Render Markdown text in SwiftUI. It is a preview based on the Marked implementation

RichTextKit is a Swift-based library for working with rich text in UIKit, AppKit and SwiftUI.
RichTextKit is a Swift-based library for working with rich text in UIKit, AppKit and SwiftUI.

About RichTextKit RichTextKit is a Swift-based library that lets you work with rich text in UIKit, AppKit and SwiftUI. RichTextKit is under developmen

iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more apps having maps.

MVAutocompletePlaceSearchTextField iOS - Subclass of UITextField to achieve autocompletion for Place Search like Google Places, Uber and Much more app

AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.
AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

AEOTPTextField - A beautiful iOS OTP Text Field library, written in Swift with full access customization in UI.

A beautiful and flexible text field control implementation of
A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift.

SkyFloatingLabelTextField SkyFloatingLabelTextField is a beautiful, flexible and customizable implementation of the space saving "Float Label Pattern"

Handles some of the base configuration to make creating a UIAlertController with text entry even easier. Plus validation!
Handles some of the base configuration to make creating a UIAlertController with text entry even easier. Plus validation!

🍅 FancyTextEntryController A simpler/easier API for adding text fields to UIAlertControllers. Not a custom view, just uses good ol' UIAlertController

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time
ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time. This is perfect for automatically suggesting the domain as a user types an email address, #hashtag or @alexruperez.

UITextField and UITextView subclasses with placeholders that change into floating labels when the fields are populated with text.
UITextField and UITextView subclasses with placeholders that change into floating labels when the fields are populated with text.

Deprecated Please use JVFloatLabeledTextField instead or feel free to chime in on an issue if you'd like to take over the repo. RPFloatingPlaceholders

UITextField that automatically formats text to display in the currency format
UITextField that automatically formats text to display in the currency format

CurrencyTextField The numbers that the user enters in the field are automatically formatted to display in the dollar amount format. For example, if th

Comments
  • Too long text description not working | Around 2000 lines

    Too long text description not working | Around 2000 lines

    Hello Author,

    Thank you for this Wonderful library.

    I have just identified an issue. When the text is too long (around 2000 lines) the Text showing only 1 line with Read More button. When tapping on Read More it is expanding but up to certain limit not entire 2000 lines.

    Can you please check this scenario at your end and provide solution ASAP? As I've integrated this library in live project, I need to provide solution as soon as possible.

    Example text (which is not working)

    Welcome all to the ChelseaFC Community here you can get the latest update on our players fan community groups Welcome all to the ChelseaFC Community here you can get the latest update on our players fan community groupsWelcome all to the ChelseaFC Community here you can get the latest update on our players fan community groupsWelcome all to the ChelseaFC Community here you can get the latest update on our players fan community groupsWelcome all to the ChelseaFC Community here you can get the latest update on our players fan community groups Welcome all to the ChelseaFC Community here you can get the latest update on our players fan community groups

    Thank you, Rashesh

    opened by RasheshAccenture 2
  • Expanded | Collapse

    Expanded | Collapse

    Once expanded, How can I collapse? e.g. I want to collapse on tap on label like toggle. Tap to expand and again tap to collapse.

    Even I want different font and colour for read more button.

    enhancement 
    opened by RasheshAccenture 2
  • Text is being repeated when view is in the collapsed state with the

    Text is being repeated when view is in the collapsed state with the "more"

    To reproduce this error you will need to enter a very long piece of text. For me I used:

    How to win Friends and Influence People: I gave myself the challenge in the year of 2022 to read more. My goal is to read 1 book a month, so 12 books by the end of the year. I just finished this classic book. This has been overdue on my reading list for a while, and I’m so glad I read it. There are so many valuable lessons that help with how you communicate with people. Some of my favorites include:

    1. Be heavy on your praise and avoid criticizing.
    2. Talk about what people enjoy and are interested in, instead of talking about what I’m interested in all the time.
    3. Avoid an argument in the first place. Nothing productive is done once people are in the mindset of an argument.
    4. Be genuine with compliments. Really think what’s something about them that you really admire and then let them know.
    5. Put yourself in their shoes, appreciate and understand the world the way others see it. At the end of the day we are a product of our environments, and given a different situation or circumstance you might hold the same views as the person you think is wrong. P.S. - This book is definitely one that really needs to be read multiple times to internalize the messages. In addition, these mindset changes need to be actively practiced to properly develop. I will definitely need to work on this still.

    ^Try this text out with the Expandable Text and it will cause the bug of repeating text.

    opened by shahsarth 1
Releases(1.2.0)
Owner
null
SwiftUI TextEdit View - A proof-of-concept text edit component in SwiftUI & CoreText.

A proof-of-concept text edit component in SwiftUI & CoreText. No UIKit, No AppKit, no UITextView/NSTextView/UITextField involved.

Marcin Krzyzanowski 80 Dec 1, 2022
This project will add done button on TexField and TextViews by just turning on from storyboard.

RTDoneKeyboard Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation RTD

Rahul Tiwari 0 Oct 29, 2021
This project will add a done button on your UITextField and UITextView

This project will add a done button on your UITextField and UITextView

Botla Venkatesh 0 Nov 23, 2021
Library that allows you binding `enabled` property of button with textable elements (TextView, TextField)

What is NxEnabled? It's a fairly common case, when the enabled state of button depends on some textable elements such as TextView, TextField. So this

Nikita Ermolenko 33 Sep 20, 2021
A SwiftUI TextField with a prompt (or placeholder) that floats above the text field when active or not empty. Requires iOS 15.

FloatingPromptTextField A prompt is the label in a text field that informs the user about the kind of content the text field expects. In a default Tex

Emilio Peláez 43 Nov 3, 2022
Render Markdown text in SwiftUI

MarkdownUI MarkdownUI is a library for rendering Markdown in SwiftUI, fully compliant with the CommonMark Spec. Supported Platforms You can use the Ma

Guille Gonzalez 916 Jan 8, 2023
Focus text field in SwiftUI dynamically and progress through form using iOS keyboard.

Focuser Focuser allows to focus SwiftUI text fields dynamically and implements ability move go through the form using Keyboard for iOS 13 and iOS 14.

Art Technologies 118 Dec 25, 2022
Autocomplete for a text field in SwiftUI using async/await

Autocomplete for a text field in SwiftUI using async/await

Dmytro Anokhin 13 Oct 21, 2022
Currency text field formatter available for UIKit and SwiftUI 💶✏️

CurrencyText provides lightweight libraries for formating text field text as currency, available for both UIKit and SwiftUI. Its main core, the Curren

Felipe Lefèvre Marino 183 Dec 15, 2022
Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen in Apple's TV & TestFlight iOS apps.

SwiftUI Matched Inline Title Transition from any SwiftUI Text view into an inline navigation bar title when the view is scrolled off-screen, as seen i

Seb Jachec 19 Oct 9, 2022