A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.nativescript.org/ui/button below:

Button | NativeScript

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

For more information about the available gestures, see Gestures.

xml
<Button text="This is a button!" />
html
<button text="This is a button!" (tap)="tapMe($event)"></button>
tsx
<button
  onTap={() => {
    alert('Button Clicked')
  }}
>
  Click Me
</button>
tsx
<button on:tap={() => alert('button clicked')}>Click Me</button>
svelte
<button text="this is a button" on:tap={showAlert}></button>
vue
<Button text="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>
    <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 text

Sets the text shown in the button.

textWrap

Gets or sets whether the button should wrap longer text to new lines.

Default value is false.

isEnabled

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) => {
  const button = args.object as Button
  console.log(`The button has been tapped!`)
})

Emitted when the button is tapped

See TapGestureEventData.

Native component

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4