Badge
In ProgressDark modeRTLA small status indicator with multiple variants.
Installation
Copy the component into your project using the CLI:
$ronakcn add badge
Usage
Import and use the component in your Flutter widget tree:
lib/pages/example.dart
import 'package:flutter/material.dart';
import '../components/badge/badge.dart';
class ExamplePage extends StatelessWidget {
const ExamplePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('RcnBadge Example')),
body: Center(
child: RcnBadge(
// Configure props here
),
),
);
}
}Variants
Badge ships with the following variants:
default
The default filled badge.
secondary
A secondary muted badge.
destructive
A red destructive badge.
outline
A badge with only a border.
success
A green success badge.
warning
An amber warning badge.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
label* | String | — | Text displayed inside the badge. |
variant | BadgeVariant | BadgeVariant.defaultVariant | Visual style of the badge. |
Source files
lib/components/ui/badge.dart
import 'package:flutter/material.dart';
enum BadgeVariant { defaultVariant, secondary, destructive, outline }
class RnBadge extends StatelessWidget {
const RnBadge({
super.key,
required this.label,
this.variant = BadgeVariant.defaultVariant,
});
final String label;
final BadgeVariant variant;
@override
Widget build(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 2),
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.primary,
borderRadius: BorderRadius.circular(9999),
),
child: Text(
label,
style: TextStyle(
color: Theme.of(context).colorScheme.onPrimary,
fontSize: 12,
fontWeight: FontWeight.w600,
),
),
);
}
}Version
0.1.0 · display category