Button
<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 documentation.
import { EventData } from '@nativescript/core'
;<button
text="Button"
onTap={(args: EventData) => {
const button = args.object
}}
/>
<button text="Button" on:tap="{onButtonTap}" />
<button text="Button" @tap="onButtonTap" />
Props
Name | Type | Description |
---|---|---|
|
|
Sets the label of the button. |
|
|
Gets or sets whether the widget wraps the text of the label.
Useful for longer labels.
Default value is |
`isEnabled ` |
|
Make the button disabled or enabled.
A disabled button is unusable and un-clickable.
Default value is |
|
|
Additional inherited properties not shown. Refer to the API Reference |
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>