0.2.0 • Published 6 months ago

react-native-custom-buttons v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

react-native-custom-buttons

react native custom button based on pure JavaScript with good expansibility.

Installation

npm install react-native-custom-buttons

Setup

If you want to use icons install react-native-vector-icons

npm install react-native-vector-icons

Buttons Component

Props

PropRequiredTypeDescription
onPressYesFunctionCallback function to be executed on button press.
containerStylesNoViewStyleCustom styles for the button container.
typeYes"Text", "SVG", or "vector Icon"Type of button. Choose one

iconProps

PropRequiredTypeDescription
fontFamilyYes'AntDesign', 'Entypo', ...Font family for the icon.
iconSizeNoNumberSize of the icon. Default is 20.
iconNameYesStringName of the icon.
iconColorYesColorValueColor of the icon.

textProps

PropRequiredTypeDescription
titleNoStringText content for the button.
textStyleNoTextStyleCustom styles for the text.

svgProps

PropRequiredTypeDescription
childrenNoReactNodeChild components for the SVG button.

loadingProps

PropRequiredTypeDescription
isLoadingNoBooleanIndicates if the button is in a loading state.
loaderColorNoColorValueColor of the loading indicator.
loaderSizeNoNumber or 'small' or 'large' or undefinedSize of the loading indicator. Default is small.

Example Usage

import Buttons from 'path/to/Buttons';

const IconButton = () => (
  <Buttons
    onPress={() => console.log('Icon button pressed')}
    type="vector Icon"
    fontFamily="FontAwesome"
    iconSize={30}
    iconName="star"
    iconColor="yellow"
  />
);

const TextButton = () => (
  <Buttons
    onPress={() => console.log('Text button pressed')}
    type="Text"
    title="Click me"
    textStyle={{ color: 'white' }}
  />
);

const SVGButton = () => (
  <Buttons
    onPress={() => console.log('SVG button pressed')}
    type="SVG"
  >
    {/* Your SVG component here */}
  </Buttons>
);

For a usage example, refer to the example directory in the repository.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT