Launch sale! Get 30% OFF expires in 126:46:22

Existing member? Log in and continue learning

See if you like it, start the course for free!

Unlock full course by purchasing a membership
Styling and Theming
Styling and Theming
We are basically done at this point — the application is functional… it’s just not particularly good looking.
Displaying a message when no checklists are available
Instead of just display text when there are no checklists available, let’s utilise Ionic’s card component to display the message.
} @empty { <ion-card> <ion-card-header> <h2>Welcome!</h2> </ion-card-header> <ion-card-content> <p>Click the add button to create your first quicklist</p> </ion-card-content> </ion-card> }
} @empty { <ion-card> <ion-card-header> <h2>Add an item</h2> </ion-card-header> <ion-card-content> <p>Click the add button to add your first item to this quicklist</p> </ion-card-content> </ion-card> }
Add presenting element for modals
This is mostly just a stylistic change but it does require some code changes. By setting a presenting element, we can get cooler mobile looking popups for our modals (you will see what I mean if you enable the device emulator in Chrome DevTools and set it to simulate a mobile device).
I will leave this one up to you a little bit.
presentingElement = signal<HTMLElement | null>(null);
afterNextRender(() => { this.presentingElement.set(document.querySelector('.ion-page')); });
[presentingElement]="presentingElement()"
Scroll to bottom when checklists change
This one isn’t really a problem initially, but if you create enough checklists or items to fill the entire page, when you add a new one you won’t see it (because it will be off the bottom of the page). We are going to add some code so that when a new checklist or item is added, we automatically scroll to the bottom of the page.
ionContent = viewChild.required(IonContent);
effect(() => { this.checklistService.checklists(); setTimeout(() => { this.ionContent().scrollToBottom(200); }, 0); });
Close sliding items after editing
Now let’s do a similar thing to automatically close our sliding items list after an edit.
checklistList = viewChild.required(IonList);
<ion-item-option color="light" (click)=" edit.emit(checklist); checklistList().closeSlidingItems() ">
Global Styles
We have two main files that affect the global styling of our application:
src/theme/variables.scss
where most of our CSS variables are definedsrc/global.scss
where we place any custom CSS styles we want to apply globally
Let’s start by providing some modified theme variable values.
Thanks for checking out the preview of this lesson!
You do not have the appropriate membership to view the full lesson. If you would like full access to this module you can view membership options (or log in if you are already have an appropriate membership).