Bottom aligned chat interface with CSS

While designing a chat interface for an AI product recently, I was using React-Native and so quickly reached for LegendList to have a performant list that could easily be bottom aligned for expected UX. I found however, that LegendList gave me some weird vibrating UI elements.

LegendList was in beta, so I’m sure it’s probably fine and I’m using it wrong, however, performance wasn’t really something I needed to solve, so I ditched it in favour of just doing it in basic CSS.

Bluesky
Threads
Twitter / X
Mastodon
Instagram

The solution

I’ll provide my approach in standard CSS, even though what I used was tailored for ReactNative.

The core of the solution is really just that the chat container applies a “column-reverse” value. This causes it’s contained elements to align to the opposite end of the column. ie. The bottom.

Everything else in this CSS is just to help it fill the screen or look slightly nicer.

.overallContainer {
    display: flex;
    height: 100%;
}
.chatContainer {
    flex: 1,
    display: flex;
    flex-direction: "column-reverse";
    gap: 10px;
}
.chatBubble {
    ...
}

When you apply the column-reverse value, though, it will display the messages in the opposite order to normally. So while chat windows usually display the newest message last, your array holding the messages should have the newest messages first.

const chatHistory = [
    message1,
    message2,
    message3,
    message4,
]

Thanks…

I also dissect and speculate on design and development.
Digging into subtle details and implications, and exploring broad perspectives and potential paradigm shifts.
Check out my conceptual articles on Substack or find my latest below.


You can also find me on Threads, Bluesky, Mastodon, or xTwitter for more diverse posts about ongoing projects.

My latest articles

Storyboarding Immersive Experiences

Storyboarding 360 degree immersive experiences requires a different approach to traditional media…

Staging XR scenes (Keep doing your crappy little drawings)

Some people create beautiful perspective illustrations to visualise and storyboard their virtual reality designs And it’s tempting to think you’re not a strong designer if you’re not doing that too…

Focal point blocking for XR media

Planning out a linear VR experience requires thinking about where the viewers attention might be. Thinking about the focal points…

Designing immersive experiences

In traditional cinema, TV, or even the more modern phone screen, there’s limited screen real-estate. But removing that limitation creates a design problem…

The future is not prompt engineered

Let’s not pretend the importance of prompt engineering is ubiquitous. The most prevalent power of generative AI is in the way it adapts to us, not the other way around…

The typography of dates, times, & filenames

A deep dive into carefully considered date formatting, line length and general typography attributes of filenames…
Bluesky
Threads
Twitter / X
Mastodon
Instagram


Author:

Date:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.