JReviews logo
Guides My site
← All guides Community guide

Style custom field options separately

Alejandro
Thread started by Alejandro. Contributors Alejandro.
Thread started
Last updated

What you’ll achieve

Use field option values as CSS classes to target individual select, radio, or checkbox options.

My site

Platform
JReviews version

Give each displayed select, radio, or checkbox option a CSS class based on its stored value so you can style the options separately. This changes field output on listings. It does not style choices inside an edit-form dropdown.

Add an option class in Output Format

Edit the custom field's Output Format. The following format adds the stored option value as a CSS class and displays the option's label:

<span class="{optionvalue}">{fieldtext}</span>

Choose stored option values suitable for CSS class names. The example field is jr_choices, with values one, two, and three.

JReviews 6 Early Access

Style the field options

In Configuration > Early Access Settings, enable Listing Detail Page for detail-page field output, or Listing List Pages for list-page output. Enable both if you style both pages. These page switches are independent.

Field output uses the data-field attribute:

[data-field="jr_choices"] .one { color: #165b32; }
[data-field="jr_choices"] .two { color: #8a291e; }
[data-field="jr_choices"] .three { color: #234f91; }

JReviews 5 and v6 Legacy

Style the field options

Field rows use a CSS class derived from the field name, such as .jrChoices for jr_choices. Match the capitalization shown in your page HTML:

.jrChoices .one { color: #165b32; }

.jrChoices .two { color: #8a291e; }

.jrChoices .three { color: #234f91; }

Use your actual rendered field class, including capitalization. Change the colors to suit your site.

Use an optional class prefix consistently

If you prefer a prefix, replace the format from Add an option class in Output Format with:

<span class="choice-{optionvalue}">{fieldtext}</span>

Then use the matching prefixed selectors:

.choice-one { color: #165b32; }

.choice-two { color: #8a291e; }

.choice-three { color: #234f91; }

Save the CSS in your overrides

Joomla. Add your CSS rules to templates/jreviews_overrides/resources/css/custom.css.

WordPress. Add your CSS rules to jreviews_overrides/resources/css/custom.css.

Create the file if it does not exist. Keep existing rules. JReviews loads this stylesheet after its own styles.

Use an active custom JReviews theme. If you do not have one, create and select one with the custom-theme setup.

Joomla. Save the CSS rules in templates/jreviews_overrides/views/themes/{your-theme}/theme_css/custom_styles.css.

WordPress. Save the CSS rules in jreviews_overrides/views/themes/{your-theme}/theme_css/custom_styles.css.

Replace {your-theme} with the active custom theme's folder. Start a new stylesheet empty and add only your rules. Clear Cache & File Registry after adding a new file.

Check the option styles

Choose one format and its matching selectors. Add the CSS to your site's override stylesheet. Display a listing with each option and confirm that only the intended option changes. No PHP hook is needed.

Learn more