Hello everyone!
I believe i haven't red the (pdf) guide till the end, but i've been googling for some examples or hints on how to style an object/element the css way.
There are config options including some styling (class and css) for an object but not an example to be seen.
Please those who know gimme link or something. Thanx
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Styling examples
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Styling examples
Hi,
Just to clarify — are you looking to style an object on specific form, or are you trying to apply styling to a specific object on all forms in general? Let me know, and I can try to point you in the right direction!
Just to clarify — are you looking to style an object on specific form, or are you trying to apply styling to a specific object on all forms in general? Let me know, and I can try to point you in the right direction!
Re: Styling examples
For now just just single object on a specific form, although i'll probably wish to apply slightly different styles for some labels (say Commentary field) globally. So please point to both examples
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Styling examples
Yes, exactly. To style a single object, you can either:
Select CSS and enter a CSS style, such as
or
Choose Class and enter a class name that you define in the form’s Style field—for example,
Select CSS and enter a CSS style, such as
background-color:red
or multiple styles like background-color:red; color:white
or
Choose Class and enter a class name that you define in the form’s Style field—for example,
fancy-button
—or a class name that is defined elsewhere, such as in the Header or an external stylesheet.You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Styling examples
Use JavaScript in the form's Custom Code field, e.g.
Code: Select all
function styleObjectLabel(elementId, cssStyle) {
const labelId = `label_${elementId}`;
$(`#${labelId}`).css(cssStyle);
}
// Apply red color and bold font to the label for the element with ID "sus_name"
styleObjectLabel("sus_name", {
color: "red",
fontWeight: "bold"
});
Re: Styling examples
good workaround, thanks kev1n. Ideally it would be good for user be able to apply additional class specificly to Label and thus have such labels styled consistently. I mean here i have some ojects on the form which are read-only (merely informative) and to have them distincty labeled (say a bit smaller fontSize, grayer-color & italic) would be visually nice and somewhat standing out.
This is just an addition to my wishlist for future releases, appreciate it
This is just an addition to my wishlist for future releases, appreciate it
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Styling examples
Uzlander wrote: ↑Wed Apr 30, 2025 8:55 am Ideally it would be good for user be able to apply additional class specificly to Label and thus have such labels styled consistently. I mean here i have some ojects on the form which are read-only (merely informative) and to have them distincty labeled (say a bit smaller fontSize, grayer-color & italic) would be visually nice and somewhat standing out.
This shouldn't be too difficult:
Setup -> Style:
Code: Select all
.readonly-label {
font-size: 0.9em;
color: gray;
font-style: italic;
}
Code: Select all
// Functions placed here are available anywhere in nuBuilder Forte.
function styleReadonlyLabels(className = "readonly-label") {
$("input[readonly], input:disabled, textarea[readonly], textarea:disabled, select:disabled").each(function () {
const elementId = $(this).attr("id");
if (elementId) {
const labelId = `label_${elementId}`;
$(`#${labelId}`).addClass(className);
}
});
}
// Runs after each Edit Form loads
function nuLoadEditGlobal(formId, formCode) {
styleReadonlyLabels();
}
// Runs after each Browse Form loads
function nuLoadBrowseGlobal(formId, formCode) {
}
// Runs after each Edit and Browse Form loads
function nuOnLoad(formId, formCode) {
}
// Include external resources:
</script>
<script>