Back to Chromium

Component Spec: Badge

agents/projects/chrome-design-system/assets/component-specs/Badge_Spec.md

153.0.7995.12.8 KB
Original Source

Component Spec: Badge

This specification document outlines the mapping, design tokens, styling variants, and interactive states of the Badge component across Figma, C++ Views, and WebUI (Web Frontend).


Overview

The Badge component is a highly compact, informational text label (commonly rendering text like "NEW"). It is placed alongside other components to highlight updates or new features.


1. Component Metadata & Source Files

FeatureFigma ComponentC++ Views (Desktop)WebUI (Web Frontend)
Component NameBadgeviews::BadgeCustom CSS / new-badge
Source FilesFigma Link: 280:26503ui/views/controls/badge.hui/webui/resources/cr_components/help_bubble/new_badge.ts

2. Styling, Variants & Features (Layout & Style)

Figma VariantC++ views::Badge MethodWebUI Element/Class
Default (Tonal Container)Not natively supported.new-badge or custom
Cocoa Menu (Primary)views::Badge standard behavior<new-badge> / Custom

3. Component States

This component is non-interactive.

Interactive StateFigmaC++ views::BadgeWebUI
DefaultN/ANormal paintingNormal layout

4. Design Token Comparison (Side-by-Side)

Token TypeFigma PropertyC++ ViewsWebUI Variable / CSS
TypographySpecial Label (9px, Bold)Custom font listfont-weight: bold; font-size: 9px
Padding4pxNative layoutpadding: 4px
Corner Radius4pxNative drawingborder-radius: 4px
Default ColorTonal ContainerN/ACSS specific
Cocoa ColorPrimaryHardcoded blueCSS specific

5. Architectural & Implementation Gaps

  • Theme Toggles: The views::Badge in C++ hardcodes its rendering to a blue background. Custom colors (like the Tonal Container variant seen in Figma) require overriding or creating a new View.
  • WebUI <new-badge>: Some WebUI systems use specialized components like <new-badge> (from user education frameworks) instead of a universal CSS primitive.

6. Styling, Variants, Features and States Mismatches

  • Typography size: A 9px font size is extremely small and may be scaled up automatically by OS-level text scaling settings, deviating from pure Figma mockups.

7. Usage & UX Guidance

1. General Principles & Best Practices

  • Brevity: Badges should contain 1-3 characters maximum (e.g., "NEW", "PRO").

8. Inheritance Structure

  • C++ Views (Desktop): views::Viewviews::Badge
  • WebUI (Web Frontend): N/A