https://github.com/mikayelgr/cobadge
Unopinionated, easy-to-use, and customizable Badge component for Jetpack Compose
https://github.com/mikayelgr/cobadge
android android-library badge component jetpack-compose kotlin kotlin-android kotlin-library library ui
Last synced: over 1 year ago
JSON representation
Unopinionated, easy-to-use, and customizable Badge component for Jetpack Compose
- Host: GitHub
- URL: https://github.com/mikayelgr/cobadge
- Owner: mikayelgr
- License: apache-2.0
- Created: 2021-08-13T03:33:27.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-12-19T11:09:54.000Z (over 4 years ago)
- Last Synced: 2025-03-19T23:35:00.301Z (over 1 year ago)
- Topics: android, android-library, badge, component, jetpack-compose, kotlin, kotlin-android, kotlin-library, library, ui
- Language: Kotlin
- Homepage: https://jitpack.io/#michaelgrigoryan25/cobadge
- Size: 162 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Cobadge
🗻 Unopinionated, easy-to-use, and customizable Badge component for Jetpack Compose
# Getting started
In this section I will walk you through the steps to add Cobadge to your Android app.
### Add the JitPack repository to your build file
Add this line at the end of `repositories`:
```groovy
maven { url 'https://jitpack.io' }
```
If your project is set to fail on project repositories, then add that line to `settings.gradle` file in `repositories` field, so that it looks approximately like this
```groovy
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "Your application"
```
### Add the dependency and replace `Tag` with the latest version.
Latest version is indicated below:
[](https://jitpack.io/#michaelgrigoryan25/cobadge)
Groovy
```groovy
implementation 'com.github.michaelgrigoryan25:cobadge:Tag'
```
Kotlin DSL
```kotlin
implementation("com.github.michaelgrigoryan25:cobadge:Tag")
```
# Usage
Using Cobadge is really easy! Here's an example:
```kotlin
Badge(
color = Color200,
text = "Hello World"
)
```
Here are all the options that Cobadge takes. Fortunately, most of them are optional.
```kotlin
// Badge text
text: String,
// Badge background color
color: Color,
// Badge size (calculated automatically)
size: Size = Size.MD,
// Outer badge padding
paddingSelf: Dp = 4.dp,
// Supports clicking
isClickable: Boolean = true,
// Badge rounding (calculated automatically)
rounded: Rounding = Rounding.XL,
// Badge background color transparency
backgroundColorOpacity: Float = 1f,
// Badge text color
textColor: Color = Color.Unspecified,
// Action that is going to get triggered on click
onClickAction: () -> Unit = {},
// Badge text font weight
fontWeight: FontWeight = FontWeight.Bold
```
# Contributions
Contributions to Cobadge are welcome! Saw a bug? [Create a pull request!](https://github.com/michaelgrigoryan25/cobadge/issues/new) Have a suggestion? [Create an issue](https://github.com/michaelgrigoryan25/cobadge/issues/new) or [start a discussion!](https://github.com/michaelgrigoryan25/cobadge/discussions/new)
_Author: Michael Grigoryan_
