Default Image

Button

A button means an operation (or a series of operations). Clicking a button will trigger corresponding business logic.

import { Button } from '@redshank/native';

How to use

In @redshank we provide 4 types of button ready for use.

  • solid
  • flat
  • link
  • outline

Examples

Default

You can display an button

Shape

You can display two shape

Outline

Outline variant

Flat

Flat variant

Link

Link variant

Shadow

Shadow property

Icon

Icon, Prefix and Suffix property

APIs

Button Props

Api props extends from Touchable

AttributeTypeAccepted valuesDescriptionDefault
ComponentComponentReact ComponentChange the element baseRipple
borderRadiusnumbernumberDefined border radius in components8 or 20
childrenstring ReactNodeanyAccessory as a child for the component-
colorThemeColor stringThemeColorChange icon colorprimrary
contentStyleobjectStyleProp<ViewStyle>Style for wrapper text-
disableRipplebooleantrue falseDisable ripple animation effectfalse
disableTransformbooleantrue falseDisable transform scale animation effectfalse
disabledbooleantrue falseDisable element, prevent click in elementfalse
fullWidthbooleantrue falseThe button gets the width of 100% of the containertrue
iconReactNodeReactNodeThe prefix icon for the element-
loadingbooleantrue falseShow loading state for the buttonfalse
prefixReactNodeReactNodeThe prefix icon for the element, related to icon prop-
shadowbooleantrue falseShow shadow effect in the buttonfalse
shapeEnumcircle roundBorder type between circle or roundedround
sizeButtonSizeButtonSizeSize element for showmiddle
styleobjectStyleProp<ViewStyle>Style button wrapper-
suffixReactNodeReactNodeShow icon on the other side of the button-
suffixOrPrefixStyleobjectStyleProp<ViewStyle>Style for prefix or suffix element-
textAlignobjectleft center rightPosition of the childrencenter
textColorThemeColorThemeColorColor for the text of the buttonautomatic white or black
textPropsobjectTextPropsText accessories props-
textStyleStyleProp<TextStyle>TextStyleText style-
typeButtonTypeButtonTypeButton variant typesolid
withMarginBottombooleantrue falseMargin bottom in the element for separate viewsfalse
Other PropsanyOther propsInteractive props for element-

Base Properties

type BaseProperties = {
  onBlur?: ((e: NativeSyntheticEvent<TargetedEvent>) => void) | undefined;
  onFocus?: ((e: NativeSyntheticEvent<TargetedEvent>) => void) | undefined;
  onLayout?: ((event: LayoutChangeEvent) => void) | undefined;
  onLongPress?: ((event: GestureResponderEvent) => void) | undefined;
  onPress?: ((event: GestureResponderEvent) => void) | undefined;
  onPressIn?: ((event: GestureResponderEvent) => void) | undefined;
  onPressOut?: ((event: GestureResponderEvent) => void) | undefined;
};

Size Type

type ButtonSize =
  'small'
  | 'middle'
  | 'large'
  | 'xLarge'

Button Type

type ButtonType =
  'solid'
  | 'link'
  | 'flat'
  | 'outline'

Community:

We're excited to see the community adopt @redshank/native, raise issues, and provide feedback. Whether it's a feature request, bug report, or a project to showcase, please get involved!

DiscordGithub

Contributing:

PR's on @redshank/native are always welcome, please see our contribution guidelines to learn how you can contribute to this project.

Copyright © 2023 @redshank.