Other Built-in Components

These are built-in components that you might need in actual projects; they are not strictly required, but can be very useful. All of them can be imported from @adminui-dev/antd-layout. For example:

import { LazyImage } from "@adminui-dev/antd-layout"

LazyImage

A lazy-loading image component. It does not include a placeholder; instead, it features a fade-in animation once the image has finished loading. It inherits all standard React.ImgHTMLAttributes<HTMLImageElement> properties. Usage:

import { LazyImage } from "@adminui-dev/antd-layout"

const imgStyles:React.CSSProperties = {
    position:"absolute",
    transition:"width 0.3s, height 0.3s, opacity 0.3s"
}
export default(){
    return(
        <div>
            <LazyImage style={imgStyles} src="/images/skins/park-waves-dark/aside-bg-dark.webp" alt="aisde-bg.webp" />
        </div>
    )
}

Additional properties:

PropertyTypeDefaultDescription
hasChildboolean-Used for “shell removal” (unwrapping)

SpinImage

A lazy-loading image component that includes a Spin (loading) effect and a placeholder. Example:

import { SpinImage } from "@adminui-dev/antd-layout"

export default(){
    return(
        <div>
            <SpinImage src="/images/welcome.webp" alt="welcome.webp" />
        </div>
    )
}

Additional properties:

PropertyTypeDefaultDescription
hasChildboolean-Used for “shell removal” (unwrapping)

LazyAvatar

A lazy-loading Avatar component. It accepts and returns the same properties as the native Avatar component from ant-design. Example:

import { LazyAvatar } from "@adminui-dev/antd-layout"

export default(){
    return(
        <div>
            <LazyAvatar shape="square" size={32} src="/images/user.webp" alt="user.webp" />
        </div>
    )
}

LazyPage

A component designed specifically for lazy-loading pages. It is a wrapper around react.lazy that incorporates an nprogress progress bar. It is typically used when configuring routes. Example usage:

import { LazyPage } from "@adminui-dev/antd-layout"
import { createBrowserRouter, redirect } from "react-router-dom"

const DashboardLayout = LazyPage(() => import("@/layouts"))
const WelcomePage = LazyPage(()=>import("@/pages/welcome"))

const routers = createBrowserRouter(
    [
        { path: "/", Component: DashboardLayout, children: [
            { path: "/welcome", Component: WelcomePage }
        ]}
    ]
)
export { routers }