Changing username colors

AI-generated summary

Changing Username Colors Based on Groups

It is possible to change the colors of usernames based on groups using CSS. vinothkannans provided an example to change the color of admin usernames to red and moderators to purple:

.topic-post .admin a {
color: red;
}

.topic-post .moderator a {
color: purple;
}

For custom groups, dylanh724 found that replacing .admin or .moderator with the group_name works. Additionally, a more extensive method using .names can be used to style multiple groups:

.names {
  span.someGroup a  {
    color: #DC2E17;
  }
  span.someOtherGroup a {
    color: #DC2E17;
  }
}

Note that the group must be set as the user’s “Primary Group” for this to work.

Is there currently any way to change the colors of usernames based on groups?
For example, I want to make the usernames of Admins show up red when they post, and moderators purple when they post?

Yes you can do via CSS like below. But if you prioritized names in Discourse then only names will be colored. Also group must be chosen as “Primary Group” for that user.

.topic-post .admin a {
color: red;
}

.topic-post .moderator a {
color: purple;
}

Old bump, but super relevant – can I do the same css for custom groups? Eg, groups I made for Patreon linking I’d like to have a unique color.

Got it: Replace .admin .moderator with group_name, similarly. Or beyond just posts:

// TOP TAKES PRIORITY
.names {
  span.someGroup a  {
    color: #DC2E17;
  }
  span.someOtherGroup a {
    color: #DC2E17;
  }
}