Theme Skins

In addition to supporting basic light/dark modes and monochromatic themes, antd-layout offers extensive customization of its visual appearance through images and animations—it can even be transformed to adopt a shadcn-ui style.

Note: The content in this section focuses exclusively on “Skin”

System Skins

Official skin themes can be installed into your project using npx create-antd-skin@latest. System skins will be added periodically.

Installing a System Skin

  1. Run npx create-antd-skin@latest <skin-name>.
  2. If you are unsure of the <skin-name>, you can omit it; a list of available skins will be displayed for you to choose from (completing the installation).
  3. Set the skinName property within LayoutConfig (../layout-config#layoutconfig) to activate the skin.

Custom Theme Skins

Based on the ThemeSkin constraints provided by antd-layout, you can define more detailed properties and combine them with image-based background assets to create a skin component.

These skins can then be imported into the system just like menu and i18n data. Finally, set skinName in layoutConfig to activate the theme skin.

Design Guidelines

The design of a “skin” (theme) should highlight the core visual theme. It must center on the product’s primary color palette, with design elements that align with the product’s overall conceptual direction. Specific requirements include:

Creating a Custom Skin

src/components/skins/blueSkyDark.ts
import type { ThemeSkin } from "@adminui-dev/antd-layout"

const BackgroundElement = <div><img style={{width:"100%"}} src="/images/skins/blue-sky/bg.webp" alt="bg.webp" /></div>

const blueSkyDark:ThemeSkin = {
    "name":"blueSkyDark",    
    "skinType":"custom",
    "backgroundColor":"#090a0b",
    "layoutConfig":{
        "theme":"dark",
        "primaryColor":"#4dbae9",        
        "noneHeader":false,
        "hideBorder":false,
        "asideBlur":true,
        "headerBlur":true,
        "largeBrand":true,
        "containerBlur":true,
        "menuItemSelectColor":"primary",
    },        
    "logo":"/images/skins/blue-sky/app-logo-light.webp",
    "icon":"/images/skins/blue-sky/skin-icon-dark.webp",
    "backgroundContent":{BackgroundElement}
}
export { blueSkyDark }
Copied!

The core component of a theme skin is backgroundContent. It can be a JSX element, or it can be implemented as a functional component (Component) to achieve a richer variety of effects:

src/components/skins/blueSkyDark.tsx
import { LazyImage } from "@adminui-dev/antd-layout"
import type { ThemeSkin } from "@adminui-dev/antd-layout"
import { Grid } from "antd"
const { useBreakpoint } = Grid

const ImageBackground=()=>{
    const { xs } = useBreakpoint()
    const leftStyle = xs ? {"height":"100%"} : {"width:":"260px"}
    return (
        <div style={skinBgStyles}>
        <LazyImage style={{...leftStyle,...imgStyles,top:"0px"}} src="/images/skins/park-waves-dark/aside-bg-dark.webp" alt="aisde-bg.webp" />
        <LazyImage style={{...imgStyles,width:"90%",top:"0px",right:"0px"}} src="/images/skins/park-waves-dark/header-bg-dark.webp" alt="header-bg.webp" />
        <LazyImage style={{...imgStyles,height:"80px",bottom:"0px",right:"0px"}} src="/images/skins/park-waves-dark/footer-bg-dark.webp" alt="header-bg.webp" />
        </div>
    )
}

const blueSkyDark:ThemeSkin = {
    "name":"blueSkyDark",
    "skinType":"custom",
    "backgroundColor":"#090a0b",
    "layoutConfig":{
    "theme":"dark",
    "primaryColor":"#4dbae9",
    "noneHeader":false,
    "hideBorder":false,
    "asideBlur":true,
    "headerBlur":true,
    "largeBrand":true,
    "containerBlur":true,
    "menuItemSelectColor":"primary",
    }, 
    "logo":"/images/skins/blue-sky/app-logo-light.webp",
    "icon":"/images/skins/blue-sky/skin-icon-dark.webp",
    "backgroundContent":<ImageBackground />
}
export { blueSkyDark }
Copied!

The example above intentionally incorporates features such as multiple images, responsive breakpoints (useBreakpoint), and image lazy loading (LazyImage) to serve as a reference template.

  1. You can also use the defineThemeSkin helper for a cleaner definition: const blueSkyDark = defineThemeSkin({...})
  2. The logo parameter in ThemeSkin will override the logo parameter found under BrandInfo within LayoutConfig;

Using a Skin

src/layouts/index.tsx
import { blueSkyDark } from "@components/skins/blueSkyDark"
import { AntdLayout } from "@adminui-dev/antd-layout"
...
export default function(){   
    // layout config
    const layoutConfig:LayoutConfig = {
        disabledLocale:true,
        largeBrand:true,    
        skinName:"blueSkyDark", // Using a Skin
    }
    return(
        <AntdLayout layoutConfig={layoutConfig} menuData={...} themeSkins={[blueSkyDark]}>        
    )
}
Copied!

Once a skin is enabled, it is no longer possible to switch the Theme or primaryColor; the corresponding UI elements and components should be removed. themeSkins accepts an array because multiple skins can be registered.

Switching Skins

const layoutConfig:LayoutConfig = {
    kinName:"blueSkyLight",
}
src/pages/welcome.tsx
import { setSkinConfig, useConfigAction, useConfigState } from '@adminui-dev/antd-layout';

export default function(){
    const { setLayoutConfig } = useConfigAction();
    const { layoutConfig } = useConfigState();

    const onCleanSkin=()=>{         
        setLayoutConfig({
            ...layoutConfig,
            skinName:''
        })
    }
    return(
        <button onClick={()=>{onCleanSkin()}>Change</button>
    )
}
Copied!

Skin Resource Structure

This structure ensures that both system-installed skin themes and your own custom-defined skin themes follow a consistent, standardized format.

your-project/
├── public/                                    # Global assets directory
│   └── images/                                # Images directory
│       └── skins/                             # Skin resources directory
│           ├── blue-sky-dark/                 # A specific skin resource directory
│           │   ├── aside-bg-dark.webp         # Image asset
│           │   ├── header-bg-dark.webp        # Image asset
│           │   └── footer-bg-dark.webp        # Image asset
│           └── blue-sky-light/                # Another skin resource directory
│               ├── aside-bg-light.webp        # Image asset
│               ├── header-bg-light.webp       # Image asset
│               └── footer-bg-light.webp       # Image asset
├── src/                                       # Project source code directory
│   ├── components/                            # Project components directory
│   │   └── warden-skins/                      # Skin themes directory
│   │       ├── blue-sky-dark/                 # A specific skin theme
│   │       │   └── index.tsx                  # Skin component
│   │       ├── blue-sky-light/                # Another skin theme
│   │       │   └── index.tsx                  # Skin component
│   │       └── index.tsx                      # Central export for all skin components
│   ├── layouts/                               # Layouts directory
│   │   ├── index.tsx                          # Main layout component (skins are loaded and used here)
│   │   └── menuData.tsx
│   ├── locales/                               # Localization directory (unrelated to skins)
│   └── pages/                                 # Pages directory (unrelated to skins)
├── tsconfig.json                              # Unrelated to skins
└── package.json                               # Unrelated to skins

Note on loading and using skins: themeSkins={[blueSkyDark, blueSkyLight]} loads these two skins into the layout component; however, this does not yet apply them. The actual application occurs only when configured within LayoutConfig. You must specify a skin—for example, skinName:"blueSkyDark"—to officially enable it.

Skin Properties

ThemeSkin

NameTypeDefaultDescription
namestring-Unique identifier
labelstring-Display name
descriptionstring-Description
authorstring-Author
skinTypeSkinTypecustomSkin type
layoutConfigLayoutConfig-Layout configuration overrides
antdTokenjson-ant-design token
logostring / ReactNode-Brand logo
iconstring-Skin thumbnail
headerStylestring-Header style
asideStylestring-Sidebar style

SkinType