N
Nuxt2mo ago
pearbender

nuxt ui page help

need help creating a wiki-style page
17 Replies
kapa.ai
kapa.ai2mo ago
Hi @pearbender. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- To create a wiki-style page using Nuxt UI (specifically with Nuxt UI Pro), you can leverage the UPage component for a grid layout with optional left and right columns—ideal for documentation or wiki-like layouts. Here’s a basic example of how you can structure such a page:
<script setup lang="ts">
const route = useRoute()

definePageMeta({
layout: 'docs'
})

const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('content').path(route.path).first()
})

const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
return queryCollectionItemSurroundings('content', route.path)
})
</script>

<template>
<UPage>
<UPageHeader :title="page.title" :description="page.description" />

<UPageBody>
<ContentRenderer :value="page" />

<USeparator />

<UContentSurround :surround="surround" />
</UPageBody>

<template #right>
<UContentToc :links="page.body.toc.links" />
</template>
</UPage>
</template>
<script setup lang="ts">
const route = useRoute()

definePageMeta({
layout: 'docs'
})

const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('content').path(route.path).first()
})

const { data: surround } = await useAsyncData(`${route.path}-surround`, () => {
return queryCollectionItemSurroundings('content', route.path)
})
</script>

<template>
<UPage>
<UPageHeader :title="page.title" :description="page.description" />

<UPageBody>
<ContentRenderer :value="page" />

<USeparator />

<UContentSurround :surround="surround" />
</UPageBody>

<template #right>
<UContentToc :links="page.body.toc.links" />
</template>
</UPage>
</template>
Key points: - The UPage component provides the main layout. - Use the right slot for a table of contents (UContentToc), which is common in wiki pages. - The main content is rendered with ContentRenderer. - You can add navigation or other components in the left slot if needed. This setup assumes you are using Nuxt Content for your markdown-based content, which is a common approach for wiki/documentation sites. For more advanced features, explore additional Nuxt UI Pro components like UContentNavigation for navigation trees and UContentSurround for prev/next navigation links. For more details and examples, see the UPage documentation and Nuxt Content installation guide for setting up your content structure and rendering logic. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@779279431419559947> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
pearbender
pearbenderOP2mo ago
@kapa.ai Like i want a title, then a few different sections analogous to h2
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- To create a wiki-style page with a title and several sections (like h2 headings) using Nuxt UI Pro and Nuxt Content, you can use the UPage, UPageHeader, and UPageBody components. Your markdown content will be rendered with proper heading styles automatically when using ContentRenderer, thanks to Nuxt UI Pro’s typography integration. Here’s a typical setup:
<script setup lang="ts">
const route = useRoute()

definePageMeta({
layout: 'docs'
})

const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('content').path(route.path).first()
})
</script>

<template>
<UPage>
<UPageHeader :title="page.title" :description="page.description" />

<UPageBody>
<ContentRenderer :value="page" />
</UPageBody>
</UPage>
</template>
<script setup lang="ts">
const route = useRoute()

definePageMeta({
layout: 'docs'
})

const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('content').path(route.path).first()
})
</script>

<template>
<UPage>
<UPageHeader :title="page.title" :description="page.description" />

<UPageBody>
<ContentRenderer :value="page" />
</UPageBody>
</UPage>
</template>
How it works: - The page title and description are shown in the header. - Your markdown file (e.g., content/wiki/my-page.md) should use # for the main title and ## for sections:
# My Wiki Page Title

## Section One

Content for section one.

## Section Two

Content for section two.

# My Wiki Page Title

## Section One

Content for section one.

## Section Two

Content for section two.

- When rendered, Nuxt UI Pro will style the headings (h1, h2, etc.) beautifully and consistently, with no extra configuration needed if you use ContentRenderer and have Nuxt UI Pro installed and configured for typographyUsage. If you want to customize the appearance of headings, you can do so in your app.config.ts using the uiPro.prose optionsH1. This approach gives you a clean, wiki-style layout with a title and multiple sections, leveraging Nuxt Content and Nuxt UI Pro components. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@779279431419559947> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
pearbender
pearbenderOP2mo ago
@kapa.ai i don't literally want to render markdown. i want to style the page with components
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- If you want to create a wiki-style page using Nuxt UI Pro components (not rendering markdown), you can compose your page using components like UPage, UPageHeader, UPageBody, and UPageSection. This gives you full control over the structure and styling, while still achieving a documentation/wiki look. Here’s an example of how you can structure such a page:
<template>
<UPage>
<UPageHeader
title="Wiki Page Title"
description="A short description of this wiki page."
/>

<UPageBody>
<UPageSection
title="Section 1"
description="This is the first section of the wiki page."
>
<!-- Add your content or components for Section 1 here -->
</UPageSection>

<UPageSection
title="Section 2"
description="This is the second section of the wiki page."
>
<!-- Add your content or components for Section 2 here -->
</UPageSection>

<!-- Add more sections as needed -->
</UPageBody>
</UPage>
</template>
<template>
<UPage>
<UPageHeader
title="Wiki Page Title"
description="A short description of this wiki page."
/>

<UPageBody>
<UPageSection
title="Section 1"
description="This is the first section of the wiki page."
>
<!-- Add your content or components for Section 1 here -->
</UPageSection>

<UPageSection
title="Section 2"
description="This is the second section of the wiki page."
>
<!-- Add your content or components for Section 2 here -->
</UPageSection>

<!-- Add more sections as needed -->
</UPageBody>
</UPage>
</template>
- UPage provides the main layout grid. - UPageHeader displays the page title and description. - Each UPageSection acts like an H2 section, with its own title and description, and you can place any content or further components inside. You can further customize each section with icons, headlines, or even use UPageFeature for feature highlights. This approach gives you a clean, component-driven wiki/documentation layout without relying on markdown rendering, fully leveraging Nuxt UI Pro’s design system and flexibility PageSection PageHeader PageBody Page. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@779279431419559947> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
pearbender
pearbenderOP2mo ago
why is everything ceneted @kapa.ai why is everything centered
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- The centering of content in Nuxt UI Pro components like UPage, UPageHeader, UPageBody, and UPageSection is determined by their default theme and slot classes. According to the documentation, many of these components use flexbox and grid layouts with classes that align and justify content centrally, especially on smaller screens. For example, the UPage component's default layout is a centered single column if no left or right slots are provided. UPageHeader and UPageSection also use classes that center text and content by default, particularly in their vertical orientation or on mobile devices. This is intentional to provide a clean, readable layout out of the box, but you can override these styles using the ui prop or by customizing the theme in your app.config.ts Page PageHeader PageSection. If you want to left-align content, you can: - Use the horizontal orientation variant where available (e.g., for UPageSection or UPageHeader). - Override the default slot or container classes via the ui prop or by customizing your theme in app.config.ts. This flexibility allows you to adapt the layout to your specific needs. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@779279431419559947> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
pearbender
pearbenderOP2mo ago
@kapa.ai can you show me how to customize app.config.ts for this
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- Certainly! To customize the alignment and other styles of Nuxt UI Pro components like UPage, UPageHeader, and UPageSection, you can override their slot classes in your app.config.ts file. This allows you to control layout details such as alignment. For example, to left-align the content in UPageHeader and UPageSection, you can update their slot classes as follows:
export default defineAppConfig({
uiPro: {
pageHeader: {
slots: {
// Remove or adjust 'text-center' and use flex utilities for left alignment
wrapper: 'flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4',
title: 'text-3xl sm:text-4xl text-pretty font-bold text-highlighted text-left',
description: 'text-lg text-pretty text-muted text-left',
// ...other slots as needed
}
},
pageSection: {
slots: {
// Remove 'text-center' and use left-aligned classes
title: 'text-3xl sm:text-4xl lg:text-5xl text-pretty tracking-tight font-bold text-highlighted text-left',
description: 'text-base sm:text-lg text-muted text-left',
// ...other slots as needed
},
variants: {
orientation: {
horizontal: {
container: 'lg:grid-cols-2 lg:items-center',
description: 'text-pretty text-left',
features: 'gap-4'
}
}
}
}
}
})
export default defineAppConfig({
uiPro: {
pageHeader: {
slots: {
// Remove or adjust 'text-center' and use flex utilities for left alignment
wrapper: 'flex flex-col lg:flex-row lg:items-center lg:justify-between gap-4',
title: 'text-3xl sm:text-4xl text-pretty font-bold text-highlighted text-left',
description: 'text-lg text-pretty text-muted text-left',
// ...other slots as needed
}
},
pageSection: {
slots: {
// Remove 'text-center' and use left-aligned classes
title: 'text-3xl sm:text-4xl lg:text-5xl text-pretty tracking-tight font-bold text-highlighted text-left',
description: 'text-base sm:text-lg text-muted text-left',
// ...other slots as needed
},
variants: {
orientation: {
horizontal: {
container: 'lg:grid-cols-2 lg:items-center',
description: 'text-pretty text-left',
features: 'gap-4'
}
}
}
}
}
})
This configuration will override the default centering and apply left alignment to the relevant slots. You can further adjust other slots or add/remove utility classes as needed for your design. For more details on available slots and their default classes, refer to the UPageHeader theme and UPageSection theme documentation. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@779279431419559947> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
pearbender
pearbenderOP2mo ago
@kapa.ai it didn't seem to do anything
kapa.ai
kapa.ai2mo ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I'm sorry for the confusion. Based on the knowledge sources, customizing alignment for components like UPageHeader and UPageSection is done by overriding their slot classes in app.config.ts. However, the documentation does not explicitly state that adding text-left or removing text-center from the slot classes will always override the default alignment, especially if the component's internal structure or parent containers enforce centering via flex/grid utilities. If your changes in app.config.ts did not have any effect, it may be because: - The slot you are overriding is not responsible for the alignment you want to change. - The component's layout uses flex/grid properties that override text alignment. - There may be a need to override additional or different slots, or use the ui prop directly on the component for higher priority. The knowledge sources do not provide a detailed troubleshooting guide for this scenario, nor do they list all possible slot names or their exact effects on alignment. If the documented approach does not work, you may need to inspect the component's rendered HTML and classes to identify which slot or container controls the alignment, and override that specifically. For reference, here is how the documentation suggests overriding slot classes in app.config.ts:
export default defineAppConfig({
uiPro: {
pageHeader: {
slots: {
title: 'text-3xl sm:text-4xl text-pretty font-bold text-highlighted text-left',
description: 'text-lg text-pretty text-muted text-left'
}
}
}
})
export default defineAppConfig({
uiPro: {
pageHeader: {
slots: {
title: 'text-3xl sm:text-4xl text-pretty font-bold text-highlighted text-left',
description: 'text-lg text-pretty text-muted text-left'
}
}
}
})
But if this does not work, the knowledge sources do not provide further troubleshooting steps or alternative methods. You may need to use the ui prop directly on the component as a workaround, as this has higher priority over global configuration Config. If you need more granular control, inspecting the component's structure in your browser's dev tools may help identify the correct slot or class to override. Unfortunately, the knowledge sources do not contain enough information to provide a more specific solution. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai2mo ago
<@779279431419559947> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?