question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: more css variables for button styling

See original GitHub issue

Feature Request

Ionic version:

[x] 4.x

Describe the Feature Request

Currently (due to shadow dom) I don’t see a way to overwrite the cursors for buttons. Not even if I give them a custom class since it will be overwritten by .button-native. All of that does make sense to me and for default use cases (and consistency!). However I am doing something a bit more playful and would like to know if or how I could overwrite the cursors?

Describe Preferred Solution

Ideally I would be able to set the css variable --cursor to be able to change it. 😄

Describe Alternatives

I tried to find other ways of doing shadow piercing in angular, however the option of setting ViewEncapsulation.None does not make sense if it is an application wide style effect, that I want to have.

Related Code

In any ionic button there is a class: .button-native

.button-native {
    ...
    cursor: pointer;
    ...
}

I think the change might be as simple as making the cursor a css variable as it has been done with width and some other properties. Example: https://github.com/ionic-team/ionic/commit/bac49ca71bc3da60b1b349b7130025e2906a6ead#diff-7c58c82ca091ee01c6244994d0362292

Additional Context

   Ionic CLI                     : 6.10.1 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.1.1
   @angular-devkit/build-angular : 0.900.6
   @angular-devkit/schematics    : 9.0.6
   @angular/cli                  : 9.0.6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
liamdebeasicommented, Jun 22, 2020

Thanks for the feature request. With the launch of Ionic Framework v5.1.0 we introduced CSS Shadow Part support for our components. This lets you target internal pieces of components without knowing the actual structure of the component.

We are in the process of getting more examples out, but you would do something like this in your CSS:

ion-button::part(native) {
  cursor: grab;
}

Components that support shadow parts have the parts listed in our documentation: https://ionicframework.com/docs/api/button#css-shadow-parts.

2reactions
Eraldocommented, Jun 23, 2020

Awesome! Great move! I’ll try it tomorrow and close the issue. 😃

On Tue, Jun 23, 2020, 00:16 Liam DeBeasi notifications@github.com wrote:

Thanks for the feature request. With the launch of Ionic Framework v5.1.0 we introduced CSS Shadow Part support for our components. This lets you target internal pieces of components without knowing the actual structure of the component.

We are in the process of getting more examples out, but you would do something like this in your CSS:

ion-button::part(native) { cursor: grab; }

Components that support shadow parts have the parts listed in our documentation: https://ionicframework.com/docs/api/button#css-shadow-parts .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic/issues/21610#issuecomment-647815667, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAR5IXNPWVXPAVWSYJJZRTRX7Q6PANCNFSM4OFDIV7A .

Read more comments on GitHub >

github_iconTop Results From Across the Web

feat: more css variables for button styling · Issue #21610 · ionic ...
Currently (due to shadow dom) I don't see a way to overwrite the cursors for buttons. Not even if I give them a...
Read more >
Styling button component with CSS custom variables
Let's explore the power of CSS custom variables when styling a customizable button component. We are going to build a button component.
Read more >
Make Your CSS Dynamic with CSS Custom Properties - Toptal
CSS custom properties are somewhat like CSS's own implementation of variables. However, when used properly, they can be so much more than just...
Read more >
Building a Better Button in CSS - Cantina
We're using the <use> property of SVG to display the icons declared invisibly in the top of the document, then writing scoped selectors...
Read more >
Using variables… in CSS? - Medium
CSS variables are a powerful way of giving clear recognisable names to your colours, spacings, paddings, etc.!
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found