A Button component provides an easy-to-use way for interacting through the application and invoking custom logic in response to that. Once the user taps it, the button performs any actions attached to it.
A Button component can execute custom logic via its tap event. Handling the event is as easy as using (tap) in HTML, and implementing a tap handler in your component.
The Button component can be styled using CSS or corresponding properties.
HTML
CSS
<StackLayout><!-- No styles applied --><Buttontext="Button"></Button><!-- Using local CSS class --><Buttontext=".my-button"class="my-button"></Button><!-- Using @nativescript/theme CSS classes --><Buttontext="Button.-primary"class="-primary"></Button><Buttonclass="-primary"><FormattedString><Spantext=""class="fab"></Span><Spantext=" Button.-primary with icon"></Span></FormattedString></Button><Buttontext="Button.-outline"class="-outline"></Button><Buttontext="Button.-primary.-rounded-sm"class="-primary -rounded-sm"></Button><Buttontext="Button.-primary.-rounded-lg"class="-primary -rounded-lg"></Button><Buttontext="Button.-outline.-rounded-sm"class="-outline -rounded-sm"></Button><Buttontext="Button.-outline.-rounded-lg"class="-outline -rounded-lg"></Button><Buttontext="Button.-outline[isEnabled=false]"isEnabled="false"class="-outline"></Button><Buttontext="Button.-primary[isEnabled=false]"isEnabled="false"class="-primary"></Button></StackLayout>