https://github.com/dshatz/autosizetext-mpp-compose
AutoSizeTextView for Compose Multiplatform
https://github.com/dshatz/autosizetext-mpp-compose
android compose compose-android compose-desktop compose-library compose-multiplatform kotlin
Last synced: 12 months ago
JSON representation
AutoSizeTextView for Compose Multiplatform
- Host: GitHub
- URL: https://github.com/dshatz/autosizetext-mpp-compose
- Owner: dshatz
- License: apache-2.0
- Created: 2023-12-28T01:04:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-11T00:39:47.000Z (almost 2 years ago)
- Last Synced: 2025-01-11T18:31:42.546Z (about 1 year ago)
- Topics: android, compose, compose-android, compose-desktop, compose-library, compose-multiplatform, kotlin
- Language: Kotlin
- Homepage: https://dshatz.github.io/autosizetext-mpp-compose/
- Size: 61.5 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://opensource.org/licenses/Apache-2.0)
[](https://github.com/KevinnZou/compose-multiplatform-library-template/actions/workflows/build.yml)
[](https://github.com/KevinnZou/compose-multiplatform-library-template/actions/workflows/wiki.yml)
# AutoSizeText for [Compose Multiplatform](https://github.com/JetBrains/compose-multiplatform)
Text composable that can adjust font size depending on available space.
## Installation
Get the latest version from Maven Central: [](Version)
#### build.gradle.kts
`implementation("com.dshatz.compose-mpp:autosize-text:")`
#### build.gradle
`implementation 'com.dshatz.compose-mpp:autosize-text:'`
## Usage
```kotlin
@Composable
fun AutoSizeText(
text: String,
modifier: Modifier = Modifier,
suggestedFontSizes: ImmutableWrapper> = emptyList().toImmutableWrapper(),
minTextSize: TextUnit = TextUnit.Unspecified,
maxTextSize: TextUnit = TextUnit.Unspecified,
stepGranularityTextSize: TextUnit = TextUnit.Unspecified,
alignment: Alignment = Alignment.TopStart,
color: Color = Color.Unspecified,
fontStyle: FontStyle? = null,
fontWeight: FontWeight? = null,
fontFamily: FontFamily? = null,
letterSpacing: TextUnit = TextUnit.Unspecified,
textDecoration: TextDecoration? = null,
lineSpacingRatio: Float = 0.1F,
maxLines: Int = Int.MAX_VALUE,
onTextLayout: (TextLayoutResult) -> Unit = {},
style: TextStyle = LocalTextStyle.current
) { }
```
```kotlin
Box {
AutoSizeText(
text = "Hello world!",
minTextSize = 10.sp,
maxTextSize = 20.sp
)
}
```