Zurb, makers of Foundation, have a reputation for building robust tools that web developers love. They craft effective solutions because they start out to solve problems they encounter themselves.
Now they’re back with a brand new, open-source, ES6 JavaScript @mention engine called Tribute.js. @mention is a user interface technique for addressing someone directly. When you @mention someone, they are tagged into a conversation. The @mention was first popularized by social media sites like Twitter, but you’ll find it making its way into all manner of applications thanks to adoption by startups like Slack. Back in 2014 Zurb began merging several of their design apps into a single new platform called Notable. They needed an @mention system, but failing to find a reliable 3rd party option, they decided to build their own. The result is Tribute.js. Tribute.js is a native JavaScript solution, meaning that it avoids relying on 3rd party plugins or scripts. By avoiding libraries like jQuery, Angular, and so forth, Zurb decreased the chances of conflicts arising between Tribute.js and scripts that run in conjunction with it; which makes Tribute.js a highly usable tool that can be implemented consistently across a multitude of different applications, regardless of the other dependencies you might choose to use.How tribute.js works
Tribute.js is really simple to implement. First, import Tribute.js’ CSS and JS:<link rel="stylesheet" href="tribute.css" />
<script src="tribute.js"></script>
Next, you need an element in your markup that will display a @mention:
<input id="commentField" placeholder="Type your comment">
Lastly, initialize Tribute with an array of objects that represent your users and then attach Tribute to the page element:
<script>
var tribute = new Tribute({
values:[
{key:"John Doe", value="johndoe"},
{key:"Jane Doe", value="janedoe"}
]
});
tribute.attach(document.getElementById("commentField"));
</script>
When a user types an @ symbol, they’ll be presented with a list of usernames based on the key property, when they select one, the corresponding value property will be inserted.
You can download Tribute for free from Github, or install via npm, and you’ll find a full list of options in the documentation.
Featured image, Conversations via Steve McClanahan.
Paddi MacDonnell
Paddi MacDonnell is a designer and entrepreneur from Northern Ireland, follow her on Twitter.
Read Next
3 Essential Design Trends, November 2024
Touchable texture, distinct grids, and two-column designs are some of the most trending website design elements of…
20 Best New Websites, October 2024
Something we’re seeing more and more of is the ‘customizable’ site. Most often, this means a button to swap between…
Exciting New Tools for Designers, October 2024
We’ve got goodies for designers, developers, SEO-ers, content managers, and those of you who wear multiple hats. And,…
15 Best New Fonts, September 2024
Welcome to our roundup of the best new fonts we’ve found on the web in the previous four weeks. In this month’s edition…
By Simon Sterne
3 Essential Design Trends, October 2024
This article is brought to you by Constantino, a renowned company offering premium and affordable website design
You…
A Beginner’s Guide to Using BlueSky for Business Success
In today’s fast-paced digital world, businesses are always on the lookout for new ways to connect with their audience.…
By Louise North
The Importance of Title Tags: Tips and Tricks to Optimize for SEO
When it comes to on-page SEO, there’s one element that plays a pivotal role in both search engine rankings and user…
By Simon Sterne
20 Best New Websites, September 2024
We have a mixed bag for you with both minimalist and maximalist designs, and single pagers alongside much bigger, but…
Exciting New Tools for Designers, September 2024
This time around we are aiming to simplify life, with some light and fast analytics, an all-in-one productivity…
3 Essential Design Trends, September 2024
September's web design trends have a fun, fall feeling ... and we love it. See what's trending in website design this…
Crafting Personalized Experiences with AI
Picture this: You open Netflix, and it’s like the platform just knows what you’re in the mood for. Or maybe you’re…
By Simon Sterne
15 Best New Fonts, August 2024
Welcome to August’s roundup of the best fonts we’ve found over the last few weeks. 2024’s trend for flowing curves and…
By Ben Moss