N
Nuxt3mo ago
WiFi Plug

nuxt mdc adding margin to top how to remove it?

"<MDC v-if="hasImportantNotices" :value="noticeContent" class="border-4 border-red-700" />" I'm rendering MDC content like this '"::callout{icon="i-lucide-triangle-alert" color="warning" to="#"} This is a callout with full markdown support. ::" that is the content it's rendering. but it's for some reason adding margin to the top which throws off my page. how do i ensure it doesn't do this? I tried to add class="!m-0" but it didn/t work
2 Replies
kapa.ai
kapa.ai3mo ago
Hi @WiFi Plug. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The extra margin at the top when rendering MDC content (such as a ::callout) is likely due to default styling applied by the Prose components in Nuxt UI Pro or Nuxt Content. By default, these components add spacing (like my-5 or mt-5) for better readability in documentation, but this can interfere with custom layouts. How to remove the top margin: 1. Override Prose Styles via Configuration You can customize or remove the default margin by overriding the relevant Prose component styles in your app.config.ts (for Nuxt UI Pro):
export default defineAppConfig({
uiPro: {
prose: {
callout: {
base: '!mt-0' // Remove top margin
}
}
}
})
export default defineAppConfig({
uiPro: {
prose: {
callout: {
base: '!mt-0' // Remove top margin
}
}
}
})
Or, if you want to target all prose blocks:
export default defineAppConfig({
uiPro: {
prose: {
base: '!mt-0' // Remove top margin globally
}
}
})
export default defineAppConfig({
uiPro: {
prose: {
base: '!mt-0' // Remove top margin globally
}
}
})
This approach ensures the margin is removed at the component level, not just via a class on the wrapper, which may be overridden by more specific selectors from the Prose theme itself.
See Nuxt UI Pro Typography docs for configuration examples. 2. Check for Prose Class on the Wrapper If you are using <MDC ... /> or <ContentRenderer ... />, check if the prose class is being applied. If so, you can try to override it with a more specific selector in your CSS:
.prose > *:first-child {
margin-top: 0 !important;
}
.prose > *:first-child {
margin-top: 0 !important;
}
Or, if you know the specific element (e.g., .callout):
.prose .callout {
margin-top: 0 !important;
}
.prose .callout {
margin-top: 0 !important;
}
3. Disable Prose Styling (if not needed) If you do not want any prose styling, you can disable it by setting :prose="false" on <ContentRenderer> (if you use it directly):
<ContentRenderer :value="noticeContent" :prose="false" />
<ContentRenderer :value="noticeContent" :prose="false" />
See Content x UI v3 migration guide. --- Summary:
The margin is coming from default Prose styles. The most robust solution is to override the relevant style in your app.config.ts for the specific component, or globally for all prose content. Using !m-0 on the wrapper may not work due to CSS specificity, so configuration or a custom CSS override is recommended. If you need more granular control, inspect the rendered HTML to see which class is adding the margin and override it accordingly. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai3mo ago
<@679734274840330384> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?