Ready to get started?

Join Adocasts Plus for $8.00/mo, or sign into your account to get access to all of our lessons.

robot mascot smiling

Adding Conditional Icon, Headline, and Message Content

In this lesson, we'll make our alert's icon, headline, and message completely optional. We'll also allow our icon to be provided via slot and our headline and message via prop or slot.

Published
Dec 04, 23
Duration
5m 52s

Developer, dog lover, and burrito eater. Currently teaching AdonisJS, a fully featured NodeJS framework, and running Adocasts where I post new lessons weekly. Professionally, I work with JavaScript, .Net C#, and SQL Server.

Adocasts

Burlington, KY

Now that we have our variants out of the way, let’s focus on adding the content options for our alert which will enable us to provide our own:

  • Icon

  • Headline

  • Message

Icon Content

We kind of already have our icon conditionally added via our showIcon variable, but we can make this a lot better by instead relying on the existence of a slot.

We can conditionally check whether a slot is provided by checking for its existence on the $slots property of our component’s state. For example, we’ll be calling our icon slot icon, so we can check for its existence using $slots.icon.

Ready to get started?

Join Adocasts Plus for $8.00/mo, or sign into your account to get access to all of our lessons.

Join The Discussion! (0 Comments)

Please sign in or sign up for free to join in on the dicussion.

robot comment bubble

Be the first to Comment!