Skip to main content

Customization

Styling Form

There is a possibility to make changes in the look and feel of a form.

Custom style

Related sample: Form. Styling (custom CSS)

For this you need to take the following steps:

  • add a new CSS class(es) with desired settings in the <style> section of your HTML page or in your file with styles (don't forget to include your file on the page in this case)
<style>
.my_first_class {
/*some styles*/
}

.my_second_class {
/*some styles*/
}
</style>
  • specify the name of the created CSS class (or names of classes separated by spaces) as the value of the css property in the Form configuration:
const form = new dhx.Form("form_container", {
css:"my_first_class my_second_class"
});

For example:

<style>
.custom {
--dhx-background-primary: rgb(238, 238, 238);
--dhx-color-primary: #118d8d;
--dhx-color-primary-active: #118d8d;
--dhx-color-primary-hover: #1ad1d1;
}
</style>

<script>
const form = new dhx.Form("form_container", {
padding: 40,
width: 400,
css: "custom",
rows: [
{
type: "input",
label: "Name",
placeholder: "John Doe",
},
{
type: "input",
label: "Email",
placeholder: "jd@mail.name"
},
// more controls
]
});
</script>

Styling Form controls

Styling Form and its controls

Related sample: Form. Styling (custom CSS)

You can modify styling of Form controls as well using the css option inside the object of a related control.

<style>
.custom {
--dhx-background-primary: rgb(238, 238, 238);
--dhx-color-primary: #118d8d;
--dhx-color-primary-active: #118d8d;
--dhx-color-primary-hover: #1ad1d1;
}
.name {
--dhx-color-primary-active: #d1b81a;
}
</style>

<script>
const form = new dhx.Form("form_container", {
padding: 40,
width: 400,
css: "custom",
rows: [
{
css: "name",
type: "input",
label: "Name",
placeholder: "John Doe"
},
{
type: "input",
label: "Email",
placeholder: "jd@mail.name"
},
// more controls
]
});
</script>