Home/DriveWorks guides/How to style DriveWorks forms with CSS

How to style DriveWorks forms with CSS

DriveWorks Pro form controls can be themed with a stylesheet. Put ProjectStyles.css in the same folder as the .driveprojx file to style one project, or GroupStyles.css in the Group Content folder to style every project in the group. DriveWorks loads it automatically, with no rebuild. Project stylesheets arrived in DriveWorks 21 and the group-wide file in DriveWorks 22.

What can be styled

The Integration Theme in DriveWorks 22 and 23 exposes a set of CSS custom properties, named --dw-*, on its native form controls: text boxes, combo boxes, buttons, check boxes, and the rest. A stylesheet that sets those properties changes colors, borders, type, spacing, and corner radius across a form without touching the controls one at a time in the form designer.

Two file names are recognized:

File Where it goes What it styles
ProjectStyles.css The same folder as the project's .driveprojx file That one project
GroupStyles.css The Group Content folder Every project in the group

Both DriveWorks Desktop and DriveWorks Live pick the file up automatically. There is no SDK, no build step, and nothing to install. The stylesheet can be edited while the Form Design task is open: saving it in a text editor updates the form designer straight away. Web styling with CSS is a DriveWorks Pro feature.

DriveWorks supplies a starting file. Create a new project from the Responsive Form Project Template and copy the ProjectStyles.css it produces. See Form Design in the DriveWorks documentation.

One setting to know about on an HTTPS Live site: httpsForceSslOnResources must be True in the Integration Theme settings when a project loads a stylesheet in the background, or the browser will refuse the insecure request.

The quick way: generate the stylesheet

Writing the full set of properties by hand means deciding dozens of values that have to agree with each other: hover, selection, disabled, and focus states for every control type.

Projx Theme Builder is a free browser tool from Base 10 that derives all of them from a few choices and shows a live preview of the real controls as you go.

  1. Set the palette: a primary color, a text color, and a surface color.
  2. Set type and shape: typeface, base font size, corner radius, and density (compact, comfortable, or spacious).
  3. Optional: an accent color for links, a call-to-action color for promoted buttons, and light, dark, or system mode.
  4. Choose the scope: every control, or only controls you tag. One project, or the whole group.
  5. Download ProjectStyles.css or GroupStyles.css and drop it in place.

It runs entirely in the browser. Your colors and the generated CSS are not uploaded.

Styling only some controls

Every DriveWorks form control has a Metadata property (Form Design, General, Metadata). Whatever you type there is carried onto the rendered control, where a stylesheet can select on it, and it can be driven by a rule. The tag names below are the ones a Theme Builder stylesheet looks for; a hand-written stylesheet can use any names it likes.

  • Opt in. Generate the theme with the "only tagged controls" scope and tag the controls you want themed with styled.
  • Opt out. With the theme applied to everything, tag a control no-style and the theme leaves it alone.

Opting out matters because of one side effect: while the theme is installed, a rule-driven color on a themed control does nothing. The stylesheet wins. If a control's color is driven by a rule, for example a status field that turns red, tag it no-style.

Highlighting a button from a rule

To make a themed button reflect state, drive its Metadata from a rule instead of its color:

=If(<condition>, "selected", "")

When the rule returns selected, the theme fills the button with your primary color. This keeps the logic in DriveWorks rules and the appearance in the stylesheet.

Dark mode

A generated theme can be light, dark, or follow the user's system setting through the browser's prefers-color-scheme. If your users work in a dim shop office or on tablets, system mode is worth trying.

Hand-tuning

The generated file starts with a short block of --t-* tokens: the palette, type, and shape choices you made. Everything else is calculated from them. To adjust the theme later, change those tokens and leave the rest.

Why bother

A form in your own colors and typeface reads as your product, not a vendor's tool. That matters most once dealers or customers use the configurator, and when the form is embedded in your own site, where a mismatched form is obvious.

Common questions

Can DriveWorks forms be styled with CSS?

Yes. In DriveWorks 22 and 23, the Integration Theme exposes CSS custom properties on native form controls. A ProjectStyles.css or GroupStyles.css file sets them and DriveWorks loads it automatically.

Where do I put ProjectStyles.css?

In the same folder as the project's .driveprojx file. To style every project in a group, use GroupStyles.css in the Group Content folder instead.

What is the difference between ProjectStyles.css and GroupStyles.css?

ProjectStyles.css applies to a single project. GroupStyles.css applies to every project in the DriveWorks group.

Why did my rule-driven control color stop working after adding a theme?

The stylesheet takes precedence over a rule-driven color on a themed control. Tag that control no-style in its Metadata property so the theme leaves it alone.

Is there a free DriveWorks theme generator?

Yes. Projx Theme Builder from Base 10 Consultants generates ProjectStyles.css or GroupStyles.css for DriveWorks 22 and 23 in the browser, with a live preview. It is an independent tool, not affiliated with DriveWorks Ltd.

Base 10 Consultants is a DriveWorks Authorized Services Partner: CPQ configurators, design automation, and CAD-to-ERP integration for manufacturers.

Book a 30-minute call

Base 10 Consultants is a DriveWorks Authorized Services Partner and an independent company. This page is not written, reviewed, or endorsed by DriveWorks Ltd. DriveWorks is a trademark of DriveWorks Ltd; SOLIDWORKS is a trademark of Dassault Systèmes SolidWorks Corp. Behavior described here can differ between versions, so check the DriveWorks documentation for the version you run.