Skip to content

Button Component

The ButtonComponent provides native button styling and interactions with platform-specific behaviors.

Basic Info

Description

This component renders native buttons with Material Design styling, haptic feedback, and loading states.

How to Use

1. Web Implementation

javascript
import { useButton } from '@bagisto-native/react';

const NativeButton = ({ onClick }) => {
    const { buttonProps } = useButton({
        variant: "primary", // "primary", "secondary", "outline", "text"
        size: "medium", // "small", "medium", "large"
        fullWidth: false,
        loading: false,
        disabled: false,
        haptic: "light", // "light", "medium", "heavy", "none"
        onPress: onClick
    });

    return (
        <button {...buttonProps}>
            Add to Cart
        </button>
    );
};

2. Native Side

kotlin
navigator.registerBridgeComponent("button", ButtonComponent(this))

API Reference

PropertyTypeRequiredDescription
variantStringNoButton style: "primary", "secondary", "outline", "text"
sizeStringNoButton size: "small", "medium", "large"
fullWidthBooleanNoFull-width button
loadingBooleanNoShow loading state
disabledBooleanNoDisabled state
hapticStringNoHaptic feedback type
onPressFunctionNoPress callback

Button Variants

VariantDescription
primaryFilled primary action button
secondarySecondary filled button
outlineOutlined button
textText-only button

Button Sizes

SizeHeightUse Case
small32dpCompact UIs
medium40dpDefault
large48dpProminent actions

Next Steps

Released under the MIT License.