Theming
The module's components are built from Nuxt UI components and use only Nuxt UI's semantic classes (text-muted, bg-muted, border-default, the seven color names). Everything below works from your app — nothing in the module has to change.
Three levels, from broad to precise:
- Colours and design tokens — the whole app, the module included.
- Module theme in
app.config.ts— sizes and variants of the module's buttons, inputs, alerts, badges and dialogs, without touching your own. - Class names — CSS for one component or one part of it.
Colours
app/app.config.ts decides which palette stands behind each semantic colour. The module's buttons, badges, alerts and charts follow:
export default defineAppConfig({
ui: {
colors: { primary: 'emerald', neutral: 'zinc' },
},
})Only the seven semantic names render (primary, secondary, success, info, warning, error, neutral). A colour of your own is a scale of CSS variables (--color-lake-50 … --color-lake-950) in a stylesheet, then named here — see Building an admin app. No UnoCSS or Tailwind config is needed.
Design tokens
The components read Nuxt UI's CSS variables, so redefining them in a stylesheet (registered under css in nuxt.config.ts) restyles them. Define them per theme when light and dark should differ:
:root, .light {
--ui-radius: 0.375rem;
--ui-primary: var(--ui-color-primary-600);
--ui-bg: var(--ui-color-neutral-50);
}
.dark {
--ui-primary: var(--ui-color-primary-400);
--ui-bg: var(--ui-color-neutral-950);
}| Token | Used for |
|---|---|
--ui-text-muted, --ui-text-dimmed | secondary text, hints, form labels |
--ui-bg, --ui-bg-muted, --ui-bg-elevated | page, raw JSON views, cards and dialogs |
--ui-border | table and card borders |
--ui-radius | corners of every control |
--ui-chart-1 … --ui-chart-6 | chart series (1 is the primary colour) |
Dark mode is Nuxt UI's: the components have no colours of their own, so they switch with the .dark class.
Nuxt UI component config
ui.<component> in app.config.ts restyles Nuxt UI's components everywhere — the module's included:
export default defineAppConfig({
ui: {
table: { slots: { th: 'px-3 py-1.5 text-sm', td: 'px-3 py-2 text-sm' } },
card: { slots: { root: 'rounded-md shadow-none' } },
},
})This is app-wide. ui.button.defaultVariants also changes every button of your own pages, and it does not reach a button the module gives an explicit size, color or variant — for those use the module theme below.
Module theme
nuxtUiMongocamp.ui in app.config.ts sets how the module's own components look. It is organised by role — what a control is for — not by component, so one entry restyles that kind of control everywhere. Set only what you want to change; the rest keeps its default:
// app/app.config.ts
export default defineAppConfig({
nuxtUiMongocamp: {
ui: {
controlSize: 'md',
iconButton: { variant: 'soft' },
toolbarButton: { color: 'primary', variant: 'outline' },
alert: { variant: 'outline' },
modal: { lg: 'sm:max-w-4xl' },
},
},
})| Role | Default | Used for |
|---|---|---|
controlSize | 'sm' | inputs, selects and the buttons beside them in toolbars and editors |
toolbarButton | { color: 'neutral', variant: 'ghost' } | reload and other buttons in a component's toolbar |
iconButton | { color: 'neutral', variant: 'ghost', size: 'sm' } | small icon buttons: row actions (details, edit, delete), toolbar icons |
sortHeader | { color: 'neutral', variant: 'ghost' } | sortable column headers |
dialogCancel | { color: 'neutral', variant: 'ghost' } | cancel, close and back in dialogs |
dangerAction | { color: 'error' } | the confirming button of a delete or a key regeneration |
secondaryAction | { color: 'neutral', variant: 'subtle' } | copy, download, stop, compare |
compactButton | { color: 'neutral', variant: 'ghost', size: 'xs' } | small buttons in dense editors (document tree, aggregation stages) |
alert | { variant: 'subtle' } | every alert |
alertAction | { variant: 'subtle' } | a button inside an alert (retry, log in again) |
badge | { variant: 'subtle' } | every badge |
modal | { md: 'sm:max-w-xl', lg: 'sm:max-w-3xl', xl: 'sm:max-w-5xl', footer: 'justify-end' } | dialog widths (classes of the dialog's content) and footer layout |
layout | { sectionGap: 'gap-8' } | space between the sections of MongocampDashboard (stat cards, your slot content, links) — set e.g. gap-4 instead of overriding the root with !gap-4 |
The keys are typed: a wrong role or value is an error in your editor. What stays fixed on purpose:
- Colours with a meaning. A delete icon keeps
error, a regenerate iconwarning, an error alerterror, a status badge its status colour — only the variant and size around them follow the theme. Change whaterrorlooks like through colours instead. - A few deliberate one-offs: soft, link and outline buttons in the query and aggregation editors, badge sizes, the file preview drawer's width.
The theme is reactive. Switching it at runtime restyles the components without a reload:
updateAppConfig({ nuxtUiMongocamp: { ui: { controlSize: 'lg' } } })useMongocampUi() reads the resolved theme, so a button of your own in a component's toolbar slot can match: <UButton v-bind="ui.toolbarButton" … />.
Targeting a component with CSS
Every component's root element carries a fixed class: mongocamp- and its name in kebab case — MongocampUsers → mongocamp-users, MongocampCollectionData → mongocamp-collection-data. A dialog component (MongocampConfirmByName, MongocampCollectionCopy, …) carries it on the dialog itself, since a dialog is rendered at the end of the page, outside its parent.
Inside, the main parts are marked with data-mongocamp-part:
| Part | What |
|---|---|
heading | the component's own heading |
toolbar | the row with the reload button and the toolbar slot |
table | a table |
row-actions | the action buttons of a table row |
empty | an empty state |
error | the failed-load alert |
/* only the users list, only its toolbar */
.mongocamp-users [data-mongocamp-part="toolbar"] {
justify-content: flex-end;
}
/* row actions of every table: visible only on hover */
[data-mongocamp-part="row-actions"] { opacity: 0.4; }
tr:hover [data-mongocamp-part="row-actions"] { opacity: 1; }These names are part of the module's API and stay stable across releases; everything else in the markup (utility classes, element nesting) may change.
Forms
The module's dialogs are FormKit forms. It ships small default styles for FormKit's label, help text, validation message and form spacing, built on the tokens above. They load before your stylesheets, so any rule of yours wins:
.formkit-label { font-weight: 600; color: var(--ui-text); }nuxtUiMongocamp: { formkitStyles: false } drops them entirely. A formkit.config.ts of your own replaces the module's FormKit config — see Forms work without setup.
Layout
- No component brings outer padding; the page decides the spacing.
hideHeading,hideRefreshand thetoolbarslot let a page with its own header take over the title and buttons — see Page headers and toolbars.- A
classpassed to a component lands on its root element:
<MongocampUsers class="max-w-5xl mx-auto" />Avoid
font-variant-numeric: tabular-nums on whole tables: some typefaces then widen the punctuation next to figures and pull apart e-mail addresses and dates. The module already sets tabular figures on the numbers themselves.