<script setup lang="ts">
{cursor}
</script>
<template>
<Html lang="en">
<Body>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</Body>
</Html>
</template>
<style scoped>
</style>
Create a basic Nuxt app.vue
const title = 'Your Page Title'
const description = 'Your page description'
const image = 'https://yoursite.com/og.png'
const url = 'https://yoursite.com'
useHead({
titleTemplate: '%s | Your Site Name',
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1.0' },
{ name: 'charset', content: 'utf-8' },
{ name: 'color-scheme', content: 'light dark' },
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ rel: 'canonical', href: url },
],
})
useSeoMeta({
title,
description,
ogTitle: title,
ogDescription: description,
ogImage: image,
ogUrl: url,
ogType: 'website',
twitterCard: 'summary_large_image',
twitterTitle: title,
twitterDescription: description,
twitterImage: image,
})
Configure SEO meta tags and technical metadata with useHead and useSeoMeta
::component-code{pro}
---
hide:
- class
props:
class: ''
---
::
Extremely specific snippet to generate the code of a component in the Nuxt UI documentation (cc @BenjaminCanac)
export function use{clipboard}() {
const {clipboard} = ref(null);
return {
{clipboard}
};
}
Create a new Nuxt composable
const route = useRoute()
const { data: page } = await useAsyncData(route.path, () => {
return queryCollection('content').path(route.path).first()
})
Query all that stuff in your Nuxt Content collection !
icon: {
customCollections: [
{
prefix: 'custom',
dir: './app/assets/icons',
},
],
clientBundle: {
scan: true,
includeCustomCollections: true,
}
},
Create a @nuxt/icon custom collection
const modelValue = defineModel({ required: true })
Make a new model in a Vue component
---
title: New Article
description:
image:
date: {date}
tags:
- announcement
authors:
- name:
description:
to:
target: _blank
avatar:
src:
alt:
---
# New Article
Create a new Nuxt Content article
npx nuxi module add {cursor}
Install a new Nuxt module has never been so easy.
@import "tailwindcss";
@import "@nuxt/ui";
Create a basic Nuxt UI index.css
import { H3Event } from "h3";
export default defineEventHandler(async (event: H3Event) => {
const body = await readBody(event);
{cursor}
});
Create a new Nuxt server handler
<script setup lang="ts">
defineProps<{
test: string
}>()
</script>
<template>
<div>
Hello {{ test }}{cursor}
</div>
</template>
<style scoped>
</style>
Create a new Vue component with script, template, and style
npx nuxi init {cursor} --template v4-compat
Create a new Nuxt project with Nuxi CLI
<script setup lang="ts">
const items = ref([
{
label: 'Profile',
icon: 'i-lucide-user'
},
{
label: 'Billing',
icon: 'i-lucide-credit-card'
},
{
label: 'Settings',
icon: 'i-lucide-cog'
}
])
</script>
<template>
<UDropdownMenu
:items="items"
:content="{
align: 'start',
side: 'bottom',
sideOffset: 8
}"
:ui="{
content: 'w-48'
}"
>
<UButton label="Open" icon="i-lucide-menu" color="neutral" variant="outline" />
</UDropdownMenu>
</template>
Create a dropdown menu with Nuxt UI
export default defineAppConfig({
ui: {
colors: {
primary: 'green',
neutral: 'neutral'
}
}
})
Generate the UI App Config for Nuxt UI Pro
<UModal>
<UButton label="Open" color="neutral" variant="subtle" />
<template #content>
<UCard>
<p>Hello World</p>
</UCard>
</template>
</UModal>
Create a modal with Nuxt UI
<script setup lang="ts">
const items = [
{
label: 'Guide',
icon: 'i-lucide-book-open'
},
{
label: 'Composables',
icon: 'i-lucide-database'
},
{
label: 'Components',
icon: 'i-lucide-box',
slot: 'components'
}
]
</script>
<template>
<UNavigationMenu :items="items" class="w-full justify-center">
<template #components-trailing>
<UBadge label="44" variant="subtle" size="sm" />
</template>
</UNavigationMenu>
</template>
Create a navigation menu with Nuxt UI
<script setup lang="ts">
const items = ref([
{
label: 'Backlog',
value: 'backlog'
},
{
label: 'Todo',
value: 'todo'
},
{
label: 'In Progress',
value: 'in_progress'
},
{
label: 'Done',
value: 'done'
}
])
const value = ref('backlog')
</script>
<template>
<USelect v-model="value" :items="items" class="w-48" />
</template>
Create a simple select with Nuxt UI
<script setup lang="ts">
const items = ref([
{
label: 'Backlog'
},
{
label: 'Todo'
},
{
label: 'In Progress'
},
{
label: 'Done'
}
])
const value = ref({
label: 'Todo'
})
</script>
<template>
<USelectMenu v-model="value" :items="items" class="w-48" />
</template>
Create a select menu with Nuxt UI
<UTooltip text="Open on GitHub">
<UButton label="Open" color="neutral" variant="subtle" />
</UTooltip>
Create a tooltip with Nuxt UI