Skip to main content

Buttons

FlexNative Buttons package is part of FlexNative for React Native, it provides a clickable UI library and functionality.

The package include a variety of button types and styles that have extensive styles options. This flexibility allows you to quickly and easily create the exact button you need to fit your specific requirements for functionality and appearance.

Dependencies

Installation

You can installing FlexNative Buttons packages using npm:

npm i @flexnative/buttons

API

import Button from '@flexnative/buttons';

Component

Button

Type: React.Component<IButtonProps>

Properties

info

IButtonProps props extends PressableProps from react-native so any Pressable propertie from React Native it is applicable also in Buttons of @flexnative/buttons package.

NameTypeRequiredDefault ValueDescription
radiusBorderRadiusfalsemediumButton border radius. One of BorderRadius type
borderWidthBorderWidthfalsenoneOptional button borders width. One of BorderWidth type
loadingbooleanfalsefalseIt true the button it is in disabled state and it shows loading spinner while it is on loading state.
renderLoadingReact.ReactElementfalsefalseReact.ReactElement to render a custom element as loading indicator component.
disabledbooleanfalsefalseSet the button as disabled.
typeButtonTypefalsedefault
warning
To have appearance for 'text', 'link', 'ghost', with custom color you should use hex colors.
sizeSizesfalsedefaultButton Sizes. One of Sizes type.
colorButtonColorfalsetheme.color.defaultColor by theme or a custom color according react-native ColorValue.
activeColorColorValuefalseundefinedButton color on active state, according react-native ColorValue.
backgroundColorColorValuefalseundefinedButton background color.
borderColorColorValuefalseundefinedButton borders color according react-native ColorValue.
activeBorderColorColorValuefalseundefinedBorder color for active state according react-native ColorValue.
textstringITextPropstrueundefined
iconLeft keyof IconName | IconProps | React.ReactElementfalseundefinedkeyof IconName to display an icon on left side of button, or IconProps or React.ReactElement, to render a custom element at left side of button.
warning
If children it is set the text property will be ignored.
iconRightkeyof IconName | IconProps | React.ReactElementfalseundefinedkeyof IconName to display an icon on right side of button, or IconProps or React.ReactElement, to render a custom element at right side of button.
warning
If children it is set the text property will be ignored.

BorderRadius

One of 'none' | 'small' | 'medium' | 'large' | 'full' | number

NameTypeValue
nonenumber0
smallnumber2
mediumnumber4
largenumber6
fullnumber99999
numberAny number value.

BorderWidth

One of 'none' | 'hairline' | 'thin' | 'base' | 'thick' | number

NameTypeValue
nonenumber0
hairlineStyleSheet.hairlineWidthThis is defined as the width of a thin line on the platform. It can be used as the thickness of a border or division between two elements.
thinnumber1
basenumber2
thicknumber3
numberAny number value

ButtonType

One of 'default' | 'ghost' | 'inverse' | 'link' | 'text'

NameTypeDescription
defaultstringProperty to fill in solid mode the background color of the button component.
ghoststringProperty to fill the background with a transparent color the button component.
inversestringProperty to set transparent background of the button component and with solid background on press.
linkstringProperty to set transparent background of the button component width borders and with underllined text.
textstringProperty to fill the background with a transparent color the button component and with ghost background on press.

Sizes

One of 'small' | 'default' | 'medium' | 'large'

NameTypeValue
smallstringFonts size: FONT_SIZE.small
Icon size: FONT_SIZE.small
Padding Vertical: FONT_SIZE.small
Padding Horizontal: FONT_SIZE.small * 0.6
defaultstringFonts size: FONT_SIZE.default
Icon size: FONT_SIZE.default
Padding Vertical: FONT_SIZE.default
Padding Horizontal: FONT_SIZE.default * 0.6
mediumstringFonts size: FONT_SIZE.medium
Icon size: FONT_SIZE.medium
Padding Vertical: FONT_SIZE.medium
Padding Horizontal: FONT_SIZE.medium * 0.6
largestringFonts size: FONT_SIZE.large
Icon size: FONT_SIZE.large
Padding Vertical: FONT_SIZE.large
Padding Horizontal: FONT_SIZE.large * 0.6

ButtonColor

One of 'default' | 'primary' | 'secondary' | 'info' | 'success' | 'warning' | 'error' | 'dark' | 'light' | ColorValue

Name Type ValuePreview
LightDark
backgroundColorValuetheme.colors.background #f8f8f8 #000000
defaultColorValuetheme.colors.default #f5f5f5 #404040
cardColorValuetheme.colors.card #ffffff #232323
textColorValuetheme.colors.text #424242 #ffffff
borderColorValuetheme.colors.border #42424226 #ffffff1A
placeholderColorValuetheme.colors.placeholder #0000001A #FFFFFF1A
infoColorValuetheme.colors.info #3e80ed #3e80ed
successColorValuetheme.colors.success #5ec232 #5ec232
warningColorValuetheme.colors.warning #ffc107 #ffc107
errorColorValuetheme.colors.error #d51923 #d51923
darkColorValuetheme.colors.dark #424242 #424242
secondaryColorValuetheme.colors.secondary #666666 #5C5C5C
lightColorValuetheme.colors.light #ebebeb #ebebeb
primaryColorValuetheme.colors.primary #ff6358 #ff6358
ColorValueAny ColorValue chosen by developer.

ITextProps

info

ITextProps props extends TextProps from react-native so any TextProps propertie from React Native it is applicable also in text propery.

NameTypeRequiredDefault ValueDescription
colorColorValuefalseundefinedButton text color.
activeColorColorValuefalseundefinedButton text color when button it is pressed.
valuestringfalseundefinedText value to display on button component.

IconProps

info

IconProps props extends TextProps from react-native so any TextProps propertie from React Native it is applicable also in text propery.

NameTypeRequiredDefault ValueDescription
colorColorValuefalseundefinedButton icon color.
activeColorColorValuefalseundefinedButton text icon when button it is pressed.
namekeyof IconNamefalseundefinedIcon (name) to display on button component.

Usecase Examples

The following example demonstrates the FlexNative Buttons in action.

Caution

In documentation apprence of components may not be in correct way. To view the component in exact design please view the demo app.

Colors

Active Colors

Type

Border Color

Active Border Color

Border Radius

Border Width

Disabled

Icons

Icon on left side

Icon on left side

Loading

Render Loading

Sizes

Text

Render Children

Styling with StyleSheet

Playground

Live Editor
//Play with props to see live changes;

render(
  <Button
    text='Button'
    color='primary'
    activeColor='#ed143d'
    radius='full'
    size='large'
    iconLeft='star'
  />
);
Result
Loading...