Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: accessing custom props for NuxtLayout #22989

Merged
merged 8 commits into from
Sep 5, 2023
19 changes: 19 additions & 0 deletions docs/3.api/2.components/3.nuxt-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ Please note the layout name is normalized to kebab-case, so if your layout file
</NuxtLayout>
</template>
```
## Custom Props/Layout attrs
justinkekeocha marked this conversation as resolved.
Show resolved Hide resolved

`NuxtLayout` also accepts custom props that you may need to pass to the layout. These custom props are accessible via `attrs` in the Nuxt app.
justinkekeocha marked this conversation as resolved.
Show resolved Hide resolved

```vue[pages/some-page.vue]
<div>
<NuxtLayout name="custom" title="I am a custom layout">
</NuxtLayout>
</div>
```

In the above example, the value of `title` will be available using `$attrs.title` in the template or `useAttrs().title` in `<script setup>` at custom.vue.

```vue[layouts/custom.vue]
<script setup lang="ts">
const layoutCustomProps = useAttrs()
console.log(layoutCustomProps.title)//I am a custom layout
justinkekeocha marked this conversation as resolved.
Show resolved Hide resolved
</script>
```

## Layout and Transition

Expand Down