Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Adding a CSS class to a web item

Christian Selbrede
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2012

I'm adding a section of links to the top navigation bar (system.top.navigation.bar)


Is there any way I can assign to my <web-item>s a class, so I can style them with CSS?


How would I add the CSS file, so that it will work on the navbar everywhere it's requested?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 6, 2012

In your web-item's definition in the atlassian-plugin.xml, you can specify an additional XML attribute, styleClass, to inject additional CSS classes to the web-item when it is rendered.

For example:

&lt;web-item key="my-web-item" section="system.admin/configuration" styleClass="my-css-class" weight="10"&gt;
  &lt;label key="com.example.plugin.link.title"/&gt;
&lt;/web-item&gt;

I'm not 100% certain, but I'm pretty sure this is only available in JIRA 5.0+ onwards.

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 6, 2012

Ah, whoops! Sorry about that :-) Nice work working your way to the answer despite my bad instructions.

I'm not sure why it's not documented - possibly because it's not available in all situations (ie. the WebItemRenderer may choose to omit the styleClass in some circumstances). However, even with that in mind, it still would be beneficial to at least have it listed in the docs as an option... I'll chase this up with the docs team.

Christian Selbrede
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2012

Hurray!! Thank you very much! Only thing is, it's a <styleClass>my-css-class</styleClass> element of <web-item>, not an attribute. It worked great though!

Any idea why this is not documented?

Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 12, 2012

styleClass now added to the documentation here - https://developer.atlassian.com/display/CONFDEV/Web+Item+Plugin+Module

TAGS
AUG Leaders

Atlassian Community Events