BNA

BNA UI
24

A versatile button component with multiple variants, sizes, and interactive animations.

Installation

pnpm dlx bna-ui add button

Usage

import { Button } from '@/components/ui/button';
<Button onPress={() => console.log('Button pressed!')}>Click me</Button>

Examples

Default

Variants

Sizes

With Icons

Icon Only

Loading States

Disabled States

Custom Styling

Animation Control

API Reference

Button

A pressable button component with multiple variants and states.

PropTypeDefaultDescription
childrenReactNode-The button content (text or custom elements).
onPress() => void-Function called when the button is pressed.
variantButtonVariant'default'The visual style variant of the button.
sizeButtonSize'default'The size of the button.
disabledbooleanfalseWhether the button is disabled.
loadingbooleanfalseWhether the button is in loading state.
loadingVariantSpinnerVariant'default'The variant of the loading spinner.
animationbooleantrueWhether to enable press animations.
iconComponentType<LucideProps>-Icon component to display before the text.
styleViewStyle | ViewStyle[]-Additional styles for the button container.
textStyleTextStyle-Additional styles for the button text.

ButtonVariant

The available button variants:

  • 'default' - Primary button with solid background
  • 'destructive' - Red button for destructive actions
  • 'success' - Green button for success actions
  • 'outline' - Button with border and transparent background
  • 'secondary' - Secondary button with muted colors
  • 'ghost' - Button with no background
  • 'link' - Text-only button with underline

ButtonSize

The available button sizes:

  • 'default' - Standard button size (48px height)
  • 'sm' - Small button size (44px height)
  • 'lg' - Large button size (54px height)
  • 'icon' - Square button for icons only (48x48px)

Animations

The Button component features a liquid glass animation effect by default:

  • Press Animation: Scales up to 1.04x with a bouncy spring animation
  • Brightness Effect: Subtle brightness increase for a glass-like effect
  • Smooth Transitions: Uses react-native-reanimated for 60fps animations
  • Customizable: Can be disabled by setting animation={false}

Accessibility

The Button component is built with accessibility in mind:

  • Proper touch target size (minimum 44px)
  • Disabled state prevents interaction and reduces opacity
  • Loading state shows spinner with appropriate color contrast
  • Supports screen readers with proper accessibility labels
  • Responsive to system accessibility settings

Best Practices

  • Use 'default' variant for primary actions
  • Use 'outline' or 'secondary' for secondary actions
  • Use 'destructive' for delete or dangerous actions
  • Use 'ghost' for subtle actions or in dense layouts
  • Always provide meaningful onPress handlers
  • Use loading states for async operations
  • Ensure sufficient color contrast for text and backgrounds