# Button Component Documentation
## Overview
The Button component is a scalable, accessible button implementation following the XRPL Brand Design System (BDS). It supports three visual variants (Primary, Secondary, Tertiary) and two color themes (Green, Black), with comprehensive state management and smooth animations.
## Features
- **Three Variants**: Primary (solid), Secondary (outline), Tertiary (text-only)
- **Two Color Themes**: Green (default) and Black
- **Link Support**: Can render as anchor elements for navigation via `href` prop
- **Animated Arrow Icon**: Optional icon with smooth hover animations
- **Full State Support**: Enabled, Hover, Focus, Active, and Disabled states
- **Responsive Design**: Adaptive padding and spacing across breakpoints
- **Accessibility**: WCAG compliant with keyboard navigation and screen reader support
- **Smooth Animations**: 150ms transitions with custom bezier timing
## Props API
```typescript
interface ButtonProps {
/** Button variant - determines visual style */
variant?: 'primary' | 'secondary' | 'tertiary';
/** Color theme - green (default) or black */
color?: 'green' | 'black';
/**
* Force the color to remain constant regardless of theme mode.
* When true, the button color will not change between light/dark modes.
* Use this for buttons on colored backgrounds where black should stay black.
*/
forceColor?: boolean;
/** Button content/label */
children: React.ReactNode;
/** Click handler */
onClick?: () => void;
/** Disabled state */
disabled?: boolean;
/** Button type attribute */
type?: 'button' | 'submit' | 'reset';
/** Additional CSS classes */
className?: string;
/** Whether to show the arrow icon */
showIcon?: boolean;
/** Accessibility label - defaults to button text if not provided */
ariaLabel?: string;
/** URL to navigate to - renders as a Link instead of button */
href?: string;
/** Link target - only applies when href is provided */
target?: '_self' | '_blank';
}
```
### Default Values
- `variant`: `'primary'`
- `color`: `'green'`
- `forceColor`: `false`
- `disabled`: `false`
- `type`: `'button'`
- `className`: `''`
- `showIcon`: `true`
- `ariaLabel`: (derived from children text)
- `href`: `undefined`
- `target`: `'_self'`
## Variants
### Primary Button
The Primary button is used for the main call-to-action on a page. It features a solid background that fills from bottom-to-top on hover.
**Visual Characteristics:**
- Solid background (Green 300 / Black)
- High visual emphasis
- Background color transitions on hover
- Black text on green background, white text on black background
**Usage:**
```tsx
```
### Secondary Button
The Secondary button is used for supporting actions. It features an outline style with a transparent background that fills on hover.
**Visual Characteristics:**
- Transparent background with 2px border
- Medium visual emphasis
- Background fills from bottom-to-top on hover
- Green/Black text and border
**Usage:**
```tsx
```
### Tertiary Button
The Tertiary button is used for low-emphasis or contextual actions. It appears as text-only with optional underline on hover.
**Visual Characteristics:**
- Text-only, no background or border
- Lowest visual emphasis
- Underline appears on hover/focus
- Different typography (Body R token vs Label R)
**Usage:**
```tsx
```
## Color Themes
### Green Theme (Default)
The green theme uses the XRPL brand green colors:
- **Primary**: Green 300 background (#21E46B), Green 200 hover (#70EE97)
- **Secondary**: Green 400 text/border (#0DAA3E), Green 500 hover (#078139)
- **Tertiary**: Green 400 text (#0DAA3E), Green 500 hover (#078139)
### Black Theme
The black theme provides an alternative color scheme:
- **Primary**: Black background (#141414), 80% black hover
- **Secondary**: Black text/border (#141414), 15% black hover fill
- **Tertiary**: Black text (#141414)
**Usage:**
```tsx
```
### Force Color (Theme-Independent)
By default, black buttons automatically switch to green in dark mode for better visibility. However, when placing buttons on colored backgrounds (e.g., lilac, yellow, green), you may want black buttons to remain black regardless of theme mode.
Use the `forceColor` prop to prevent automatic color switching:
**Usage:**
```tsx
{/* Black button that stays black in both light and dark modes */}
{/* Useful for colored backgrounds like in FeatureTwoColumn pattern */}
```
**When to use `forceColor`:**
- Buttons on colored backgrounds (lilac, yellow, green variants)
- When you need consistent button colors regardless of user's theme preference
- Pattern components like `FeatureTwoColumn` where black text is required for readability
**Note:** The `forceColor` prop only affects the color behavior; all other button functionality (hover animations, focus states, etc.) remains the same.
## Link Buttons
The Button component can render as an anchor element for navigation by passing the `href` prop. When `href` is provided, the button is wrapped in a Redocly `Link` component for proper routing support within the application.
### How It Works
- When `href` is provided and button is not disabled, renders as `` (anchor element)
- When `href` is not provided or button is disabled, renders as `