Rüdiger
Rüdiger

Reputation: 943

How to use button styling-selectors in NativeScript

I have a NativeScript application running and now I want to change the background color of my button when it is pressed (so that the user can see, that he really pressed it). After some googling I found that documentation. So I tried to apply these to my code (sadly I am not initializing my button via TS, so I cannot use the btn = new buttonModule.Button(); line.

My html:

<Button [text]="'SIGNIN'|translate" (onTap)="passCredentials()"></Button>

My css:

Button {
    background-color: rgba(255, 230, 0, 1);
    font-weight: bold; 
    margin-left: 10;
    margin-right: 10;
    padding: 10;
    height: 50;
    margin-top: 30;
    margin-bottom: 25;
}
Button:pressed {
    background-color: red;
}

That's what I tried, but he is neither throwing an error nor changing the background-color. Do I need to tell him manually to switch between these classes? How could I do that?

Upvotes: 0

Views: 1377

Answers (2)

Pavan Vora
Pavan Vora

Reputation: 1754

No need to write css by yourself you can use NativeScript core theme.
Add one of the core theme to your app.css file and then you can use btn and btn-primary class to your Button component. Here I am sharing link for reference to import core theme to your app.css

Color Schemes

Upvotes: 1

GUISSOUMA Issam
GUISSOUMA Issam

Reputation: 2582

Try with highlighted pseudo selector:

Button:highlighted{
    background-color: red;
}

Upvotes: 1

Related Questions