While Formie aims to provide a very simple and hands-off approach to rendering your forms, it's also vitally important to be able to customise it, make it your own, and fit within the overall style of the rest of your site.
Formie provides several mechanisms for you to customise the rendering output of forms, pages and fields. This overarching term is something we call "theming" your form, and there are several ways to approach this.
A theme config refers to an object where you define what HTML tag and attributes each component of the field should use. Formie has it's own provided, but allows you to manipulate this config as you see fit. This provides you with a lot of power by setting attributes on every aspect of the form and fields, from adding or removing classes, data attributes to changing what HTML tag to use. You can even exclude HTML elements altogether, should you wish to alter the structure of components.
This is also an excellent way to have your forms work with popular front-end frameworks that rely on classes for HTML elements, like Tailwind or Bootstrap. Because you're given total control over the HTML attributes each HTML element uses, you can add utility classes to elements, and even exclude Formie's default attributes.
The main benefit to this approach that there's zero extra Twig templating involved, so you can rest easy knowing that changes to Formie's own templating wont affect your theme config, lowering your technical debt.
Continue reading about theme config.
Template overrides are the next-best thing when setting a theme config isn't enough. This is where you get back into Twig templates and have total control over how individual components of a form or field are rendered.
The beauty of template overrides is that it doesn't have to be all-or-nothing. If you want to override just a component of the form, like the submit buttons, form title, alerts, field label, field inputs, and more - you can. All while falling back on the default Formie templates for things you don't want to override.
As these template overrides are heavily tied to Form Templates you'll want to gain an understanding of how those work before diving in.
Continue reading about template overrides.
Custom Rendering is the most involved and heavy-handed approach to rendering your forms, as the entire form, page, field, etc process is entirely up to you. Compared to template overrides which acts more on the basis of tweaking a few things and overriding what you need, custom rendering is all about DIY. As such, you've got the keys to the car and you're on your own!
This can be both invigorating and daunting. We only really recommend this approach if you have very specific needs for your form, and are willing to keep it up to date as Formie changes and grows. As new features, functionality and architecture is added to Formie, there'll likely be changes that flow on to templating.
<form>
body.Continue reading about custom rendering.
While using CSS Variables won't allow you to alter the structure of HTML elements or attributes for a rendered form, you have quite a lot of flexibility with styling a form.
You can either retain Formie's CSS and override the styles we provide, or disable the CSS and go right ahead and style fui-*
classes yourself, with your framework of choice.
Continue reading about CSS variables.
Hooks are somewhat limiting compared to other approaches, but are another handy method to consider. Hooks allow you to insert Twig code at various points in the rendering process. What's limiting is you can only insert content at the locations we've placed hooks, and you are unable to remove HTML elements or attributes the default templates.
Continue reading about hooks.