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.
- Theme: Refers to the overall layout aesthetic, defined by a primary color (
primaryColor), a layout configuration (LayoutConfig), and Ant Design’s “Design Tokens.” - Skin: Involves inserting a custom canvas component—featuring images, SVGs, or animations—into the base layer of the layout. When combined with the theme’s colors, transparency settings, and effects like blur, this creates a richer, more visually appealing UI experience.
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
- Run
npx create-antd-skin@latest <skin-name>. - 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). - Set the
skinNameproperty withinLayoutConfig(../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:
- Keep the overall design clean and purely decorative; visual elements must never interfere with the UI/interactive interface.
- Whenever possible, use CSS, SVG, or Canvas instead of image files.
- Keep image file sizes to a minimum; use the WebP format and implement lazy loading (via
LazyImage). - Each theme should focus on a single style; do not attempt to support both “light” and “dark” modes within a single theme definition—these must be designed as two distinct sets.
- Anticipate the potential reuse of design assets for future pages or components (e.g., assets created for one section might also be needed for login or registration pages).
- It is typically used in conjunction with configurations such as
containerBlur,asideBlur,headerBlur, andasideTransparent(found inLayoutConfig) to create a sense of depth.
Creating a Custom Skin
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 }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:
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 }The example above intentionally incorporates features such as multiple images, responsive breakpoints (useBreakpoint), and image lazy loading (LazyImage) to serve as a reference template.
- You can also use the
defineThemeSkinhelper for a cleaner definition:const blueSkyDark = defineThemeSkin({...})- The
logoparameter inThemeSkinwill override thelogoparameter found underBrandInfowithinLayoutConfig;
Using a Skin
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]}>
)
}Once a skin is enabled, it is no longer possible to switch the
ThemeorprimaryColor; the corresponding UI elements and components should be removed.themeSkinsaccepts an array because multiple skins can be registered.
Switching Skins
- For development mode or static switching, simply configure it as follows:
const layoutConfig:LayoutConfig = {
kinName:"blueSkyLight",
}
- If dynamic switching is required, use the
setLayoutConfigmethod to perform the switch.
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>
)
}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
loadingandusingskins: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 withinLayoutConfig. You must specify a skin—for example,skinName:"blueSkyDark"—to officially enable it.
Skin Properties
ThemeSkin
| Name | Type | Default | Description |
|---|---|---|---|
| name | string | - | Unique identifier |
| label | string | - | Display name |
| description | string | - | Description |
| author | string | - | Author |
| skinType | SkinType | custom | Skin type |
| layoutConfig | LayoutConfig | - | Layout configuration overrides |
| antdToken | json | - | ant-design token |
| logo | string / ReactNode | - | Brand logo |
| icon | string | - | Skin thumbnail |
| headerStyle | string | - | Header style |
| asideStyle | string | - | Sidebar style |
SkinType
- system
string- System skin (reserved) - custom
string- Custom skin