Skip to main content

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.

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-2 and w-full.
  • Use the editor's colors by name. text-primary, text-error, bg-base-200, or text-base-content/70 for secondary text. Avoid fixed colors such as #3b82f6 or text-blue-600.
  • No custom sizes in brackets. mt-2 works; 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.

KindWhat's included
ComponentsEvery daisyUI component and variant, for example btn btn-primary btn-sm, input, select, card, modal, badge, fieldset
ColorsThe 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
SpacingMargin and padding on Tailwind's common steps up to 16, and gaps up to 12, for example mt-2, p-4, gap-3
SizeWidths and heights such as w-full, w-1/2, h-10, max-w-md
Layoutflex, grid, hidden, alignment (items-center, justify-between) and columns (grid-cols-2)
TextSizes from text-xs to text-3xl, weights such as font-bold, and truncate
Borders & effectsborder, rounded corners (rounded-box), shadows and opacity

Custom fields always use the editor's light theme.

Common Controls#


ControlMarkup
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">
Buttonsbtn btn-primary, btn btn-ghost btn-sm, btn btn-outline
Checkbox, radio, togglecheckbox, radio radio-primary, toggle
Group of controls<fieldset class="fieldset"><legend class="fieldset-legend">…
Error stateadd input-error / select-error
Dialog<dialog class="modal"><div class="modal-box">…<div class="modal-action">, opened with showModal()
Linklink 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.