Skip to main content

Button

A versatile button component with multiple variants, sizes, and states for consistent user interactions.

Installation

import { Button } from "@joe111/neo-ui";

Basic Usage

Basic Button

A simple button with primary styling

📱 Component Preview

Screenshot will be added here

Props

PropTypeDefaultDescription
variant"primary" | "secondary" | "outline" | "ghost" | "soft" | "text" | "danger" | "success" | "warning" | "info""primary"Visual variant of the button
size"xs" | "sm" | "md" | "lg" | "xl""md"Size of the button
colorButtonColorKey-Custom color from theme
fullWidthbooleanfalseWhether button takes full width
loadingbooleanfalseShow loading spinner
disabledbooleanfalseDisable button interactions
startIconReactElement-Icon to show at the start
endIconReactElement-Icon to show at the end
childrenReactNode-Button content
hapticsDisabledbooleanfalseDisable haptic feedback
onPress() => void-Required. Function called on press
onPressIn(event: GestureResponderEvent) => void-Function called on press in
onPressOut(event: GestureResponderEvent) => void-Function called on press out
styleStyleProp<ViewStyle>-Additional styles

Types

type ButtonVariant =
| "primary"
| "secondary"
| "outline"
| "ghost"
| "soft"
| "text"
| "danger"
| "success"
| "warning"
| "info";

type ButtonSize = "xs" | "sm" | "md" | "lg" | "xl";

type ButtonColorKey =
| "primary"
| "secondary"
| "accent"
| "error"
| "success"
| "warning"
| "info";

Variants

All available button variants with different visual styles for various use cases.

All Button Variants

Complete collection of button variants from primary to info

📱 Component Preview

Screenshot will be added here

Sizes

Different button sizes from extra small to extra large.

Button Sizes

Five different sizes to fit various UI contexts

📱 Component Preview

Screenshot will be added here

Colors

Custom color variants using theme colors.

Button Colors

Apply theme colors to customize button appearance

📱 Component Preview

Screenshot will be added here

States

Different button states including disabled, loading, and full width.

Button States

Various states that buttons can have for different interactions

📱 Component Preview

Screenshot will be added here

With Icons

Buttons can include icons at the start, end, or both positions.

Buttons with Icons

Enhance buttons with icons for better visual communication

📱 Component Preview

Screenshot will be added here

Icon-Only Buttons

Perfect square buttons containing only icons, ideal for toolbars and compact layouts.

Icon-Only Buttons

Square buttons with just icons, perfect for compact interfaces

📱 Component Preview

Screenshot will be added here

Icon Button Sizes

Icon-only buttons in all available sizes with proper proportions.

Icon Button Sizes

Icon buttons scaled to different sizes while maintaining aspect ratio

📱 Component Preview

Screenshot will be added here

Combined Examples

Combining different props for specific use cases.

Combined Properties

Examples showing combinations of variant, size, and color properties

📱 Component Preview

Screenshot will be added here

Interactive Examples

Real-world examples with dynamic states and user interactions.

Interactive Loading States

Buttons that demonstrate loading states and user feedback

📱 Component Preview

Screenshot will be added here

Accessibility

  • Screen Reader Support: Proper labels and roles for assistive technologies
  • Keyboard Navigation: Full keyboard support with focus management
  • Haptic Feedback: Tactile feedback on press (can be disabled)
  • System Accessibility: Respects user's accessibility preferences
  • Focus Indicators: Clear visual focus states for keyboard users
  • Loading States: Announces state changes to screen readers

Best Practices

1. Choose Appropriate Variants

  • Primary: Main actions (submit, save, continue)
  • Secondary: Secondary actions (cancel, back)
  • Outline: Alternative actions or toggle states
  • Ghost: Subtle actions or navigation
  • Danger: Destructive actions (delete, remove)

2. Consistent Sizing

  • Use consistent button sizes within the same context
  • Larger buttons for primary actions
  • Smaller buttons for secondary or compact layouts

3. Loading States

  • Always show loading states for async operations
  • Disable interaction during loading
  • Provide clear loading text

4. Icon Usage

  • Use icons to enhance button meaning
  • Keep icons simple and recognizable
  • Maintain consistent icon sizes relative to button size

5. Accessibility

  • Provide meaningful labels for screen readers
  • Use proper color contrast
  • Keep haptic feedback enabled for better UX
  • Ensure sufficient touch target size (minimum 44px)

6. Full Width Usage

  • Use full-width buttons for primary actions on mobile
  • Avoid full-width buttons in wide desktop layouts
  • Consider responsive breakpoints