Skip to main content

Overview

The SeverityBadge component displays ESLint rule severity levels with appropriate icons and colors. Built on top of the Badge component with predefined configurations for each severity level.

Import

Basic Usage

Severity Levels

The component supports four severity levels:
Red destructive variant with error icon (⊗). Indicates critical issues that must be fixed.

Props

'error' | 'warn' | 'suggestion' | 'off'
required
The severity level to display.
string
Additional CSS classes to apply.

Severity Configuration

Each severity level has a predefined configuration:

Design Details

  • Always uses the sm size variant from Badge
  • Icon is hidden from screen readers with aria-hidden="true"
  • Label text is accessible to screen readers
  • Each severity has a distinct icon and color for quick recognition

Examples

In a Rule List

With Custom Styling

All Severities

Type Exports

The component also exports the Severity type for use in TypeScript:

Component Definition

Location: packages/gadget-ui/src/components/severity-badge.tsx:17