https://github.com/ryohidaka/chrome-badge
Helper for displaying badges in chrome.action API.
https://github.com/ryohidaka/chrome-badge
badge chrome chrome-extension chrome-extensions ext
Last synced: 4 months ago
JSON representation
Helper for displaying badges in chrome.action API.
- Host: GitHub
- URL: https://github.com/ryohidaka/chrome-badge
- Owner: ryohidaka
- License: mit
- Created: 2024-01-29T09:18:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-05-01T23:38:10.000Z (about 1 year ago)
- Last Synced: 2025-08-09T03:14:28.923Z (11 months ago)
- Topics: badge, chrome, chrome-extension, chrome-extensions, ext
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/chrome-badge
- Size: 908 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# chrome-badge
[](https://badge.fury.io/js/chrome-badge)

[](https://opensource.org/licenses/MIT)
[](https://ko-fi.com/B0B6TVH92)
## Overview
Helper for displaying badges in `chrome.action` API.
## Installation
You can install this library using npm:
```shell
npm install chrome-badge
```
## Methods
### `set`
Sets the text color and background color for badge of the action. The badge is displayed on top of the icon.
```typescript
import { Badge } from "chrome-badge";
const text = "999";
const backgroundColor = "red";
const textColor = "white";
Badge.set({ text, textColor, backgroundColor });
```
### `get`
Gets the badge text of the action. If no tab is specified, the non-tab-specific badge text is returned.
```typescript
import { Alarm } from "chrome-alarms";
const badge = await Badge.get();
console.log(badge);
// Output:
// Object{
// backgroundColor: Array(4) [255, 0, 0, 255],
// text: "999",
// textColor: Array(4) [255, 255, 255, 255]
// }
```
## Link
- [chrome.action](https://developer.chrome.com/docs/extensions/reference/api/action)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.