Usage
The Error component works together with the SidebarLayout component to create a full-height layout that extends to the viewport's available height.
Error
Use the error prop to display an error message.
{
"wait": "Loading client-side content..."
}Clear
Use the clear prop to customize or hide the clear button (with false value).
You can pass any property from the Button component to customize it.
{
"wait": "Loading client-side content..."
}Redirect
Use the redirect prop to redirect the user to a different page when the clear button is clicked. Defaults to /.
{
"wait": "Loading client-side content..."
}Examples
Within error.vue
Use the Error component in your error.vue:
error.vue
<script setup lang="ts">
import type { NuxtError } from '#app'
const props = defineProps<{
error: NuxtError
}>()
</script>
<template>
<B24App>
<B24SidebarLayout :use-light-content="false">
<B24Error :error="error" />
</B24SidebarLayout>
</B24App>
</template>
You might want to replicate the code of your
app.vue inside your error.vue file to have the same layout and features, here is an example: https://github.com/bitrix24/b24ui/blob/main/docs/app/error.vueYou can read more about how to handle errors in the Nuxt documentation, but when using
nuxt generate it is recommended to add fatal: true inside your createError call to make sure the error page is displayed:pages/[...slug].vue
<script setup lang="ts">
const route = useRoute()
const { data: page } = await useAsyncData(route.path, () => queryContent(route.path).findOne())
if (!page.value) {
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
}
</script>
API
Props
Slots
Theme
app.config.ts
export default defineAppConfig({
b24ui: {
error: {
slots: {
root: 'min-h-[calc(100vh-var(--topbar-height))] flex flex-col items-center justify-center text-center',
statusCode: 'text-(length:--ui-font-size-sm) font-(--ui-font-weight-semi-bold) text-(--b24ui-typography-legend-color)',
statusMessage: 'mt-2 text-(length:--ui-font-size-4xl)/(--ui-font-line-height-md) sm:text-(length:--ui-font-size-5xl)/(--ui-font-line-height-md) font-(--ui-font-weight-bold) text-(--b24ui-typography-label-color) text-balance',
message: 'mt-4 text-(length:--ui-font-size-2xl)/(--ui-font-line-height-md) text-(--b24ui-typography-description-color) text-balance',
links: 'mt-8 flex items-center justify-center gap-6'
}
}
}
})
vite.config.ts
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import bitrix24UIPluginVite from '@bitrix24/b24ui-nuxt/vite'
export default defineConfig({
plugins: [
vue(),
bitrix24UIPluginVite({
b24ui: {
error: {
slots: {
root: 'min-h-[calc(100vh-var(--topbar-height))] flex flex-col items-center justify-center text-center',
statusCode: 'text-(length:--ui-font-size-sm) font-(--ui-font-weight-semi-bold) text-(--b24ui-typography-legend-color)',
statusMessage: 'mt-2 text-(length:--ui-font-size-4xl)/(--ui-font-line-height-md) sm:text-(length:--ui-font-size-5xl)/(--ui-font-line-height-md) font-(--ui-font-weight-bold) text-(--b24ui-typography-label-color) text-balance',
message: 'mt-4 text-(length:--ui-font-size-2xl)/(--ui-font-line-height-md) text-(--b24ui-typography-description-color) text-balance',
links: 'mt-8 flex items-center justify-center gap-6'
}
}
}
})
]
})