Documentation Index
Fetch the complete documentation index at: https://mintlify.com/aurelienbobenrieth/gadget/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheRuleExampleTabs component provides a tabbed interface for showing valid and invalid code examples for ESLint rules. Features syntax highlighting, error messages, and optional descriptions for each example.
This is a client component (
"use client") and uses React state for tab management.Import
Basic Usage
Props
Array of valid code examples.
Array of invalid code examples.
The programming language for syntax highlighting.
Additional CSS classes to apply.
HTMLAttributes<HTMLDivElement>, so all standard div attributes are supported.
CodeExample Type
Each example in thevalid or invalid arrays has the following structure:
The code to display.
Optional description of the example, displayed above the code.
Array of error messages to display below the code (typically used for invalid examples).
Tab Indicators
The component displays two tabs with distinct visual indicators:- Valid tab: Green checkmark icon (✓) with green accent when active
- Invalid tab: Red cross icon (✗) with red accent when active
Examples
Rule with Multiple Examples
JavaScript Examples
With Custom Styling
Design Details
- Tab buttons use 12px (xs) font with medium weight
- Active tab has colored text and bottom indicator
- Inactive tabs have muted text with hover effect
- Error messages displayed in destructive color with monospace font
- Examples separated by subtle dividers
- Code blocks use the CodeBlock component with syntax highlighting
- Tab list has raised surface background
Accessibility
- Uses proper ARIA attributes (
role="tab",role="tablist",role="tabpanel",aria-selected) - Focus visible outline on tab buttons
- Keyboard navigation support (inherited from button element)
Error Display
Invalid examples can include error messages that appear below the code block:Component Definition
Location:packages/gadget-ui/src/components/rule-example-tabs.tsx:78
The component uses CodeBlock internally for syntax highlighting and manages tab state with useState.