Custom Fields
Styling Custom Fields
Recommended custom fields can use daisyUI 5 components and Tailwind CSS classes, already set up with the editor's colors and shapes. A btn btn-primary looks exactly like the editor's main button, and an input like its inputs. Use these classes instead of your own colors and sizes, and your field will keep matching dotCMS when its look changes.
The full set of classes described here is available in dotCMS 26.10.05-01 and later. Earlier versions include only some of them.
Rules of Thumb#
- Start with daisyUI. Buttons, inputs, selects, checkboxes, badges, cards and dialogs all have a ready-made class (
btn,input,select,checkbox,badge,card,modal). - Tailwind for layout. Arrange and space things with classes such as
flex,gap-2,mt-2andw-full. - Use the editor's colors by name.
text-primary,text-error,bg-base-200, ortext-base-content/70for secondary text. Avoid fixed colors such as#3b82f6ortext-blue-600. - No custom sizes in brackets.
mt-2works;mt-[10px]does nothing. - Icons. The editor's icon set is available:
<i class="pi pi-sync"></i>.
Which Classes Exist#
dotCMS includes a fixed set of classes for custom fields. A class that isn't in the set simply does nothing, without any error, so check this list when something doesn't look right.
| Kind | What's included |
|---|---|
| Components | Every daisyUI component and variant, for example btn btn-primary btn-sm, input, select, card, modal, badge, fieldset |
| Colors | The editor's named colors (primary, secondary, accent, neutral, info, success, warning, error, base-100/200/300, base-content) for text, backgrounds and borders, with lighter versions /10, /20, /30, /50 and /70 |
| Spacing | Margin and padding on Tailwind's common steps up to 16, and gaps up to 12, for example mt-2, p-4, gap-3 |
| Size | Widths and heights such as w-full, w-1/2, h-10, max-w-md |
| Layout | flex, grid, hidden, alignment (items-center, justify-between) and columns (grid-cols-2) |
| Text | Sizes from text-xs to text-3xl, weights such as font-bold, and truncate |
| Borders & effects | border, rounded corners (rounded-box), shadows and opacity |
Custom fields always use the editor's light theme.
Common Controls#
| Control | Markup |
|---|---|
| Text input | <input class="input w-full"> |
| Input with a prefix | <label class="input"><span class="label">/blog/</span><input class="grow"></label> |
| Select | <select class="select w-full"> |
| Buttons | btn btn-primary, btn btn-ghost btn-sm, btn btn-outline |
| Checkbox, radio, toggle | checkbox, radio radio-primary, toggle |
| Group of controls | <fieldset class="fieldset"><legend class="fieldset-legend">… |
| Error state | add input-error / select-error |
| Dialog | <dialog class="modal"><div class="modal-box">…<div class="modal-action">, opened with showModal() |
| Link | link link-primary |
Your Own CSS#
You can add a <style> block, but its rules apply to the whole editor: a rule like input { … } changes every input on the page. Target only your own elements, for example with an id. To hide the field's label, use the Hide Label setting instead of CSS.
These styles only work in Recommended fields. Deprecated fields don't have them.