```tsx
```
### With Custom Icon
đ} />
```tsx
import { RocketIcon } from 'lucide-react';
}
/>
```
### Form Validation Errors
Email is required
Password must be at least 8 characters
Terms of service must be accepted
```tsx
```
### Status Messages
```tsx
```
## Behavior
### Dismiss Button
When `onRemove` callback is provided, a close button appears in the top-right corner. Clicking it triggers the callback:
```tsx
{
console.log('Alert dismissed');
// Hide alert or perform cleanup
}}
/>
```
### Condensed Mode
The `condensed` prop reduces vertical padding for a more compact appearance, ideal for inline notifications:
```tsx
```
## Module Augmentation
The Alert component supports TypeScript module augmentation, allowing you to add custom variants with full type safety.
### Live Example
This documentation site demonstrates module augmentation with a custom `critical` variant:
### Step 1: TypeScript Declaration
Create a declaration file (e.g., `gecko.d.ts`) in your project:
```typescript
import "@geckoui/geckoui";
declare module "@geckoui/geckoui" {
interface AlertVariantMap {
critical: unknown;
}
}
```
### Step 2: Add CSS Styles
Add the corresponding styles to your global CSS/SCSS file. You need to define both the container variant and the icon styling:
```scss
.GeckoUIAlert {
&--critical {
@apply text-purple-600;
}
&__icon {
&--critical {
@apply bg-purple-600;
mask-image: url('data:image/svg+xml,');
-webkit-mask-image: url('data:image/svg+xml,');
}
}
}
```
### Step 3: Use Your Custom Variant
```tsx
```
## Accessibility
* Uses semantic HTML with proper ARIA roles
* Dismiss button is keyboard accessible
* Color-coded icons indicate severity
* Works with screen readers
* Icon provides visual reinforcement of message type
## Styling
The component uses BEM-style class names:
* `GeckoUIAlert` - Main container
* `GeckoUIAlert--{variant}` - Variant modifier (error, success, warning, info, default)
* `GeckoUIAlert--condensed` - Applied when condensed
* `GeckoUIAlert__body` - Content wrapper
* `GeckoUIAlert__icon` - Icon element
* `GeckoUIAlert__icon--{variant}` - Variant-specific icon styling
* `GeckoUIAlert__title` - Title text
* `GeckoUIAlert__description` - Description text
* `GeckoUIAlert__remove-button` - Dismiss button
* `GeckoUIAlert__remove-button__icon` - Dismiss button icon
## Related Components
* [InputError](/docs/input-error) - Form field error messages
* [ConfirmDialog](/docs/confirm-dialog) - Confirmation prompts
* [Tooltip](/docs/tooltip) - Contextual hints
# Button
import { Button } from '@geckoui/geckoui';
import { ButtonCustomColorsExample } from '@/components/examples/module-augmentation-examples';
# Button
A flexible button component that extends the native HTML button with customizable styles. Supports different variants (filled, outlined, ghost, icon), sizes, and colors. All styling is applied via TailwindCSS classes, which can be overridden using the `className` prop.
## Installation
```tsx
import { Button } from '@geckoui/geckoui';
```
## Basic Usage
```tsx
```
## Props API
| Prop | Type | Default | Description |
| ----------- | --------------------------------------------- | ----------- | ----------------------------------- |
| `variant` | `'filled' \| 'outlined' \| 'ghost' \| 'icon'` | `'filled'` | Button visual style |
| `size` | `'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'` | `'md'` | Button size |
| `color` | `'primary'` | `'primary'` | Button color scheme |
| `disabled` | `boolean` | `false` | Disable the button |
| `className` | `string` | - | CSS class for custom styling |
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | HTML button type |
| ...rest | `ButtonHTMLAttributes` | - | All standard HTML button attributes |
## Examples
### Variants
```tsx
```
### Sizes
```tsx
```
### Outlined Buttons
```tsx
```
### Ghost Buttons
```tsx
```
### Icon Buttons
```tsx
```
### With Icons and Text
```tsx
```
### Disabled State
```tsx
```
### Form Actions
```tsx
function MyForm() {
const handleSubmit = (e) => {
e.preventDefault();
// Handle form submission
};
return (
);
}
```
## Custom Styling
The component uses TailwindCSS classes that can be overridden. By default, the button adds spacing between child elements:
```tsx
```
## Module Augmentation
The Button component supports TypeScript module augmentation, allowing you to add custom variants, colors, and sizes with full type safety.
### Live Example
This documentation site demonstrates module augmentation with custom `secondary` and `danger` colors:
### Step 1: TypeScript Declaration
Create a declaration file (e.g., `gecko.d.ts`) in your project:
```typescript
import "@geckoui/geckoui";
declare module "@geckoui/geckoui" {
interface ButtonColorMap {
secondary: unknown;
danger: unknown;
}
}
```
### Step 2: Add CSS Styles
Add the corresponding styles to your global CSS/SCSS file. The class naming follows the pattern `GeckoUIButton--{variant}-{color}`:
```scss
.GeckoUIButton {
&--filled {
&-secondary {
@apply bg-gray-600 text-white border-gray-600 enabled:hover:bg-gray-700 enabled:hover:border-gray-700 disabled:bg-gray-600/50 disabled:border-border-disabled;
}
&-danger {
@apply bg-red-600 text-white border-red-600 enabled:hover:bg-red-700 enabled:hover:border-red-700 disabled:bg-red-600/50 disabled:border-border-disabled;
}
}
&--outlined {
&-secondary {
@apply border-gray-400 text-gray-600 enabled:hover:bg-gray-50 disabled:bg-surface-hover disabled:text-text-disabled;
}
&-danger {
@apply border-red-400 text-red-600 enabled:hover:bg-red-50 disabled:bg-surface-hover disabled:text-text-disabled;
}
}
&--ghost {
&-secondary {
@apply text-gray-600 enabled:hover:bg-gray-50 disabled:text-text-disabled;
}
&-danger {
@apply text-red-600 enabled:hover:bg-red-50 disabled:text-text-disabled;
}
}
&--icon {
&-secondary {
@apply text-gray-500 disabled:text-text-disabled;
}
&-danger {
@apply text-red-500 disabled:text-text-disabled;
}
}
}
```
### Step 3: Use Your Custom Colors
```tsx
```
You can also extend `ButtonVariantMap` for custom variants or `ButtonSizeMap` for custom sizes following the same pattern.
## Accessibility
* Uses semantic `