UI Components
Button
A basic native button that reacts to user gestures.
<Button>
is a UI component that displays a button which reacts to user gestures.
For more information about the available gestures, see Gestures.
xml
<Buttontext="This is a button!" />
html
<buttontext="This is a button!"(tap)="tapMe($event)"></button>
tsx
<button
onTap={() => {
alert('Button Clicked')
}}
>
Click Me
</button>
tsx
<buttonon:tap={() =>alert('button clicked')}>Click Me</button>
svelte
<buttontext="this is a button"on:tap={showAlert}></button>
vue
<Buttontext="This is a button!" @tap="showAlert"></Button>
Examples β
Formatting text inside a Button β
If you need to style parts of the text, you can use a combination of a FormattedString
and Span
elements.
xml
<Button>
<FormattedString>
<Spantext="This text has a " />
<Spantext="red "style="color: red" />
<Spantext="piece of text. " />
<Spantext="Also, this bit is italic, "fontStyle="italic" />
<Spantext="and this bit is bold."fontWeight="bold" />
</FormattedString>
</Button>
Props β
text β
ts
text: string
Sets the text shown in the button.
textWrap β
ts
textWrap: boolean
Gets or sets whether the button should wrap longer text to new lines.
Default value is false
.
isEnabled β
ts
isEnabled: boolean
Allows disabling the button. A disabled button does not react to user gestures.
Default value is true
.
...Inherited β
For additional inherited properties, refer to the API Reference.
Events β
tap β
ts
on('tap', (args:TapGestureEventData) => {
constbutton= args.object asButton
console.log(`The button has been tapped!`)
})
Emitted when the button is tapped
See TapGestureEventData.
Native component β
- Android:
android.widget.Button
- iOS:
UIButton
- Previous
- ActivityIndicator
- Next
- DatePicker