CSS
Rationale
Form Runner has a built-in theme for forms. This page documents how you can make changes to that default style.
CSS stands for Cascading Style Sheets, and is the standard technology to add style to web pages and web applications. Orbeon Forms supports custom CSS files which allows you to change your forms' appearance. This assumes that you have some CSS knowledge.
Adding your own CSS files
Place your CSS file(s) under one of the following recommended locations:
WEB-INF/resources/forms/assets
: CSS for all formsWEB-INF/resources/forms/APP/assets
: CSS for app name APPWEB-INF/resources/forms/APP/FORM/assets
: CSS for app name APP and form name FORM
Define the
oxf.fr.css.custom.uri
property to point to the file(s) you added. The path points to location under theWEB-INF/resources
directory.
You can add more than one file, and just separate the paths by whitespace in the property.
Note that the locations suggested are just about how to organize the files for clarity. In addition, if some CSS files apply to specific app or form names, you must specify the app and form name in the property or properties. For example:
The names APP
, FORM
, my-app.css
and my-app-and-form.css
are just placeholders for your own app name, form name, and CSS files names.
If a specific property is defined for an app/form, such as oxf.fr.css.custom.uri.APP.FORM
, only that property is considered and other properties defined only for a given app but without a specific form, such as oxf.fr.css.custom.uri.APP.*
, will be ignored. This means that you must repeat references to CSS resources in the more specific property if desired. For example above /forms/APP/assets/my-app.css
is repeated.
[SINCE Orbeon Forms 2017.1]
In addition to oxf.fr.css.custom.uri
, you can also use the following properties, which apply only to the Summary and Detail pages respectively:
Authoring CSS
Disable the minimal and combined resources. When working on your CSS, you might want to temporarily set the following properties in your properties-local.xml
, which will disable the combined and minimized resources, so the files and line numbers you see in your browser correspond to what you have on disk.
Know which class names to use in your CSS selectors. We strongly recommend you use the Chrome Dev Tools to check which classes are generated by Orbeon Forms. Once you have your CSS working with Chrome and/or Firefox, it is likely that the CSS will work with other modern browsers.
Orbeon Forms CSS classes
Prefixes
Orbeon Forms standardizes on the following prefixes for CSS classes:
xforms-
: for built-in standard XForms controlsxxforms-
: for built-in extension XForms controlsfr-
: for Form Runner constructsxbl-
: for XBL components
Form structure
Class Name | Element | Comment |
---|---|---|
|
| body or enclosing embedding element |
|
| enclosing |
| enclosing element for the Form Runner view | |
|
|
|
| main form body | |
| section | |
|
| section title |
| grid |
Grids
Class Name | Element | Comment |
---|---|---|
| enclosing grid element | |
|
| indicate a repeated grid |
|
| indicate a repeated grid over a single row |
| grid head (repeated grids only) | |
| grid header row (repeated grids only) | |
| grid body (multiple for repeated grids) | |
| grid row | |
| grid header cell (repeated grids only) | |
| grid cell |
Wizard
Class Name | Comment |
---|---|
| enclosing wizard element |
| wizard table of contents |
| wizard body |
Built-in controls and components
Form controls can either be built-in or components.
Class Name | Element | Comment |
---|---|---|
| built-in control | |
|
|
|
| component | |
|
|
|
Aspects of a control or component
Built-in controls and components can have extra CSS classes.
Class Name | Comment |
---|---|
| the control is not visible (non-relevant) |
| the control is readonly |
|
|
| the control has been visited by the user, i.e. tabbed out once |
| the control has an error level |
| the control has a warning level |
| the control has an info level |
| the control is required |
| the control is required and empty |
| the control is required and filled |
| the control is in incremental mode |
|
|
|
|
|
|
| the control is in static-readonly mode |
| in static-readonly mode only, outputs which look like fields [SINCE Orbeon Forms 4.5] |
NOTE: A data type is not present if the control is xforms-disabled
.
xforms-field
applies to xf:input
, xf:secret
, xf:select
/xf:select1
. It is used to highlight (by default display a field box around) readonly fields in review and PDF modes.
Classes on other elements
Class Name | Element | Comment |
---|---|---|
| a label | |
| a help | |
| a hint | |
| an alert | |
|
| an active alert |
| radio/checkbox items | |
| wrapper around a selected checkbox/radio button | |
| wrapper around a deselected checkbox/radio button |
Other considerations
Separate vs. inline CSS
You can either:
Store your CSS is a separate CSS file, which you either provide in addition or that overrides the default CSS provided by Orbeon Forms. For more on this, see the
oxf.fr.css.custom.uri
configuration property. This is the recommended technique if your CSS is intended to be shared by several forms.Put your CSS inline, in the form. Uf your CSS is quite short, and specific to a given form (not to be shared amongst forms), this is a possibility. For this, put the rules within your own
<style>
section of the form:
NOTE: Since 2018.1, it is no longer recommended to place any inline CSS, as some servers use the Content-Security-Policy
header to disable inline scripts and CSS. Orbeon Forms 2018.1 doesn't include any inline scripts and CSS anymore by default.
Strength of CSS rules
Bootstrap, XForms engine, Form Runner and Form Builder CSS rules are contained within an enclosing .orbeon
CSS class. This ensures that the Orbeon CSS rules only apply within an element with that class. It also makes Orbeon CSS rules a bit stronger (more specific) than before. You might have to update your custom CSS to take this into account.
See here for more on CSS specificity.
When defining your own CSS, make sure to use a strong selector, so its precedence is higher than CSS provide by Orbeon Forms, e.g. something like:
Twitter Bootstrap
Since Orbeon Forms 4.0, Form Runner uses Twitter Bootstrap for some aspects of its layout and styling.
NOTE: If you have custom CSS which works with Orbeon Forms 3.9, it is likely that you will have to update it to work with Orbeon Forms 4.0.
Configuring the presentation of automatic PDF output
See Automatic PDF.
Changing the page width
The default width with Bootstrap is 940px, but you can change this by overriding the Bootstrap/Orbeon CSS. As usual, to do so, we recommend you use a tool like the Chrome DevTools to find the exact rules you need to override in your environment. For instance, with an out-of-the-box Orbeon Forms deployed as a servlet, you can set the width to 720px with:
See also
Last updated