Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CSS variables or shadow part for customizing toggle on/off label color #26021

Open
3 tasks done
brandyscarney opened this issue Sep 26, 2022 · 0 comments
Open
3 tasks done
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement

Comments

@brandyscarney
Copy link
Member

brandyscarney commented Sep 26, 2022

Prerequisites

Describe the Feature Request

The toggle component in ios currently has no way to style the on/off label colors except for by customizing --ion-color-dark or --ion-color-contrast. See the following code:

color: var(--ion-color-dark);

color: var(--ion-color-contrast, $toggle-ios-on-off-label-checked-color);

I think we should avoid having users customize the Ionic colors on a per-component basis.

Describe the Use Case

If you customize the toggle by using the following:

<ion-toggle enable-on-off-labels="true"></ion-toggle>
<ion-toggle enable-on-off-labels="true" checked="true"></ion-toggle>
ion-toggle {
  --background: #000;
  --background-checked: #f3e895;

  --handle-background: #f3e895;
  --handle-background-checked: #000;
}

You are not able to see the on/off labels in light mode. Here is a demo: https://stackblitz.com/edit/suseoe-jzo3g2?file=index.html

Describe Preferred Solution

I believe we should either add CSS variables for the color & color-checked state or we should expose it as a shadow part which would also allow users to customize the size of the labels. As it is right now they can't change the width or height either.

Describe Alternatives

No response

Related Code

https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/toggle/toggle.ios.scss#L58-L118

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Sep 26, 2022
@liamdebeasi liamdebeasi added type: feature request a new feature, enhancement, or improvement package: core @ionic/core package labels Sep 27, 2022
@ionitron-bot ionitron-bot bot removed the triage label Sep 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package type: feature request a new feature, enhancement, or improvement
Projects
None yet
Development

No branches or pull requests

2 participants