Tag
A tag puts a short category or status next to an item. Give the status a word readers can understand even if they cannot distinguish its colour.
Label a draft
#The item starts as Draft. Publish it to change its tag, then return it to Draft.
components/tag/appliance/label_draft.dart
import 'package:flutter/widgets.dart';
import 'package:appliance_ui/appliance_ui.dart';
class LabelDraft extends StatefulWidget {
const LabelDraft({super.key});
@override
State<LabelDraft> createState() => _LabelDraftState();
}
class _LabelDraftState extends State<LabelDraft> {
bool published = false;
@override
Widget build(BuildContext context) => ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 440),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ApplianceTag(
published ? 'Published' : 'Draft',
tone: published ? ApplianceTagTone.ready : ApplianceTagTone.neutral,
),
const SizedBox(height: 12),
ApplianceButton(
published ? 'Return to draft' : 'Publish',
onPressed: () => setState(() => published = !published),
),
],
),
);
}
Parameters
ApplianceTag API ↗label- Its words.
tone- What it says about its subject.
style- Its style, over ApplianceThemeData.tagStyle.
Shared behaviour
- Keyboard and focus. Tab to Publish or Return to draft. The status tag itself is a label.
- Screen readers. Read Draft or Published before and after using the action. Both states have distinct words.
- Direction and type. The tag follows the surrounding reading direction. Try the longer Published label at the larger text size.