How can I add labels in create topic form fields?

AI-generated summary

The discussion revolves around adding labels to create topic form fields in Discourse. Kamran_Afzal initially asked if there’s a plugin or custom solution available to achieve this. After sharing a design screenshot, merefield suggested four approaches to add labels, in order of preference:

  • CSS modifications
  • Using plugin outlets
  • jQuery or native JavaScript edits of the DOM
  • Altering the template (which is considered risky due to potential updates and breakages)

merefield later confirmed that modifying the CSS in the Community theme is still the recommended approach for simply adding labels. However, no solution was shared by the original author after receiving community advice.

I want to add labels in create topic form fields is there any plugin available or any custom solution?

Do you mean a template so when a user creates a new topic, there are pre-filled options just like we have on Marketplace?

Can you share a mockup or screenshot of where you want these fields?

Not exactly sure what you mean, but if you want to change the placeholder text, you can do that in the admin Customization tab, under Text. Type the current placeholder of the field and you should be able to change it.

Do you mean this?: Topic Template Placeholder Text theme component

Attached is the design screenshot which i need to implement. My question was to add the labels with text field as shown in the design

So you just want to add labels for each of the fields?

Only fields labels and some styling.

There are numerous approaches here, but consider, in order of preference:

The last option is risky, because this file will probably get a lot of updates over time (last update was 7 days ago!) and you don’t normally want to be overriding templates, especially those that frequently change, as you will mask stuff from core too much and break things.

Hi!

I’m interested in doing the same. Is modifying the CSS in our Community theme still the recommended way to go for accomplishing this? I work with a new front-end developer on my team who I can ask for help, but I’m not sure where I can point them in our theme CSS to help with this.

imho, if you just want labels, then yes, that advice stands. CSS would be the first call.

FYI It would have been nice if the original author would have shared their solution having received community advice, it is nice when people give back.