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.

[Ionic 4 RC.0] cssClass not work for Toast

See original GitHub issue

Bug Report

Ionic version:

[x] 4.x

Current behavior:

I want to customise some style of toast, here’s my cssClass

ion-toast {
  --max-width: 50%;
  --background: lightgray;
}
.my-toast {
    .toast-message {
          text-align: center;
     }
}

The max-width and background was successfully changed. However the cssClass style didn’t work.

Since v4 components have completely moved to web components and shadow dom, I can understand why max-width and background worked (the component exposes variables), but looks like cssClass is broken.

I’m really confused with how to style components now, it lost flexibility as before

Expected behavior:

Steps to reproduce:

Related code:

insert short code snippets here

Other information:

Ionic info:

Ionic:

   ionic (Ionic CLI)             : 4.6.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.0-rc.0
   @angular-devkit/build-angular : 0.11.4
   @angular-devkit/schematics    : 7.1.4
   @angular/cli                  : 7.1.4
   @ionic/angular-toolkit        : 1.2.1

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : android 7.1.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 2.3.1, (and 6 other plugins)

System:

   Android SDK Tools : 26.1.1 (/Users/Dev/Android/android-sdk-macosx)
   ios-deploy        : 1.9.4
   ios-sim           : 6.1.2
   NodeJS            : v10.14.2 (/usr/local/bin/node)
   npm               : 6.4.1
   OS                : macOS Mojave
   Xcode             : Xcode 10.1 Build version 10B61

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
paulstelzercommented, Jan 2, 2019

Thanks, but you have to check your code again (in your first issue you asked for toast, now you ask for a cssClass inside button).

You added the cssClass to the button, so it’s NOT ion-alert.my-alert, instead it’s button.my-alert (alternative add a space after ion-alert). This will work:

button.my-alert {
    color: red !important;
}

OR

ion-alert .my-alert {
    color: red !important;
}

Working:

chrome_2019-01-02_08-56-23

0reactions
ionitron-bot[bot]commented, Feb 16, 2019

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ionic 4 - Unable to change toast close button color
Thanks for your reply but I want to change the text color (for the CLOSE BUTTON) not the background color and the documentation...
Read more >
Ionic toast scss class - Angular - android - Stack Overflow
The toast work on ios (both release and debug build) and works on android debug build only. Once i build the app for...
Read more >
@ionic/core | Yarn - Package Manager
Ionic is an open source app development toolkit for building modern, fast, top-quality cross-platform native and Progressive Web Apps from a single codebase ......
Read more >
Building the EAS 2021 Conference App - Ionic Blog
A behind-the-scenes look into how we designed, built, and shipped the Enterprise App Summit 2021 app using Ionic, Capacitor, and Appflow.
Read more >
Property 'subscribe' does not exist on type 'void'. Angular 2 ...
Coding example for the question Property 'subscribe' does not exist on type ... Your get()-Function does not return the Observable -> nothing to...
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