Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 1.88 KB

File metadata and controls

61 lines (45 loc) · 1.88 KB
title apiRef contributors
Button
MisterBrownRSA
rigor789
eddyverbruggen
ikoevska

<Button> is a UI component that displays a button which reacts to a user gesture.

For more information about the available gestures, see Gestures in the official NativeScript documentation.


<Button text="Button" @tap="onButtonTap" />

[> screenshots for=Button <]

Styling the button

If you need to style parts of the text, you can use a combination of a FormattedString and Span elements.

<Button>
  <FormattedString>
    <Span text="This text has a " />
    <Span text="red " style="color: red" />
    <Span text="piece of text. " />
    <Span text="Also, this bit is italic, " fontStyle="italic" />
    <Span text="and this bit is bold." fontWeight="bold" />
  </FormattedString>
</Button>

Props

Name Type Description
text String Sets the label of the button.
textWrap Boolean Gets or sets whether the widget wraps the text of the label. Useful for longer labels. Default value is false.
isEnabled Boolean Make the button disabled or enabled. A disabled button is unusable and un-clickable. Default value is true.

Events

Name Description
tap Emitted when the button is tapped.

Child component as Button

If you want to use the event @tap on a child component. You have to use the expression : @tap.native, otherwise it wont works. Example :

<myChildComponent text="Hello There" @tap.native="myFunction" />

Native component

Android iOS
android.widget.Button UIButton