Ion-note under ion-label

Hello everyone,

I’m trying to place an ion-note under the ion-label element. The docs clearly state that it creates an element on the left or right side of an item, but you see it under de label in Android app everywhere. For example:

What is the best practice to archieve this in any other way?

Thanks in advance!

Nathan

Maybe an ion-item with 2 ion-labels, the first one being stacked

<ion-item>
<ion-label stacked> Recent </ion-label>
<ion-label> settings you changed recently </ion-label>
</ion-item>
1 Like

That would be genius, gonna try it asap :slight_smile:

Might need to add classes to the labels to manipulate font-size to your liking in the component scss file, but it should work out.

You can use html tags like <h2> and <p> inside <ion-item>. For example:

<ion-list>
  <ion-item>
    <ion-avatar item-start>
      <img src="img/avatar-finn.png">
    </ion-avatar>
    <h2>Finn</h2>
    <h3>Don't Know What To Do!</h3>
    <p>I've had a pretty messed up day. If we just...</p>
  </ion-item>
</ion-list>

See https://ionicframework.com/docs/components/#multiline-list

.ion-item-button{
  background-color: color($colors, dark);

  .ion-label-stacked{
    color: white;
    font-size:1.8rem;
  }
  .ion-label{
    margin-top:0px;
    color:lightgray;
    font-size:1.2rem;
  }
}

This is the result. It still feels like a ‘hack’ because i’m increasing stacked size and decreasing normal text-size.
Will try pwespi’s later this weekend.

Looks good. I personally don’t mind hacking a bit to get what i want, but, can’t knock you for it! Post the results when you try @pwespi’s suggestion if you can.

A quick look at the link pwepsi provided does look like it might be a cleaner solution for sure

Well me neither, whatever it takes to get it working right? Maybe I need to add a few pixels margin-top to make it look even better.

Definitely. Besides, there’s a difference between writing ‘hacky’ code and using the tools available to you.

Using your scss file to manipulate pixels, font, sizing, is just using those tools that are provided.

It’s silly because I saw this part of the documentation like a week ago. Anyway, in this case it doesn’t work. Maybe because this are ion-item-buttons. Could have fixed height or something I don’t know.

@anyone, aside from this css code working fine. Where could I request a features like this? Is GitHub the place to be?

This is working fine for me:

<ion-item>
    <ion-label>
        <h2>Recent</h2>
        <ion-note>Settings you changed recently</ion-note>
    </ion-label>
</ion-item>

No CSS needed.

4 Likes

Well the difference might be that you are using ion-items, not ion-item-buttons as I do. I think ion-items can have endless height, well ion-item-button cannot.

ion-item-button? I did not know this ionic component exists.

In the documentation, where did you find it?

My bad, there is non. You can give the an button an ion-item attribute, resulting in the list buttons a seen in the screenshot.