All Projects → luffyZh → Dynamic Antd Theme

luffyZh / Dynamic Antd Theme

Licence: mit
🌈 A simple plugin to dynamic change ant-design theme whether less or css.

Projects that are alternatives of or similar to Dynamic Antd Theme

Ant Design Vue Pro
👨🏻‍💻👩🏻‍💻 Use Ant Design Vue like a Pro!
Stars: ✭ 8,965 (+5052.3%)
Mutual labels:  antd, ant-design
Fc Angular
快速搭建angular后台管理系统的admin template。Fast development platform based on angular8, ng.ant.design built multi-tab page background management system (continuous upgrade) ^_^
Stars: ✭ 171 (-1.72%)
Mutual labels:  antd, ant-design
Awesome Uikit
Collect JS Frameworks, Web components library and Admin Template.
Stars: ✭ 1,136 (+552.87%)
Mutual labels:  antd, ant-design
Ant Design Blazor
Enterprise-class UI components based on Ant Design and Blazor.
Stars: ✭ 39 (-77.59%)
Mutual labels:  antd, ant-design
Spring Security React Ant Design Polls App
Full Stack Polls App built using Spring Boot, Spring Security, JWT, React, and Ant Design
Stars: ✭ 1,336 (+667.82%)
Mutual labels:  antd, ant-design
React Antd Todo
A simple todo list app built with React, Redux and Antd - Ant Design
Stars: ✭ 42 (-75.86%)
Mutual labels:  antd, ant-design
Ant Design Mobile
Fluent and powerful mobile component library based on React.
Stars: ✭ 9,489 (+5353.45%)
Mutual labels:  antd, ant-design
Ng Zorro Antd Mobile
A configurable Mobile UI components based on Ant Design Mobile and Angular. 🐜
Stars: ✭ 709 (+307.47%)
Mutual labels:  antd, ant-design
React Antd Admin
用React和Ant Design搭建的一个通用管理后台
Stars: ✭ 1,313 (+654.6%)
Mutual labels:  antd, ant-design
Ant Back
🚀 react后台,后台管理系统
Stars: ✭ 90 (-48.28%)
Mutual labels:  antd, ant-design
Ng Zorro Antd
Angular UI Component Library based on Ant Design
Stars: ✭ 7,841 (+4406.32%)
Mutual labels:  antd, ant-design
Vuepress Theme Antdocs
🔥🎨 An Ant Design style theme for VuePress. (QQ Group: 867711329)
Stars: ✭ 147 (-15.52%)
Mutual labels:  antd, ant-design
Ant Design Pro
👨🏻‍💻👩🏻‍💻 Use Ant Design like a Pro!
Stars: ✭ 30,909 (+17663.79%)
Mutual labels:  antd, ant-design
React Redux Antdesign Webpack Starter
react + redux + ant design + react-router 4 + webpack 4 starter
Stars: ✭ 44 (-74.71%)
Mutual labels:  antd, ant-design
Bowtie
Create a dashboard with python!
Stars: ✭ 724 (+316.09%)
Mutual labels:  antd, ant-design
React Antd Multi Tabs Admin
ts+react+antd-多页签后台模板(纯净版,非 antd pro!)
Stars: ✭ 73 (-58.05%)
Mutual labels:  antd, ant-design
React Admin
✨ react-admin system solution : react 后台管理系统解决方案
Stars: ✭ 5,975 (+3333.91%)
Mutual labels:  antd, ant-design
React Design Editor
React Design Editor has started to developed direct manipulation of editable design tools like Powerpoint, We've developed it with reactjs, ant.design, fabricjs
Stars: ✭ 687 (+294.83%)
Mutual labels:  antd, ant-design
Ant Design Pro Plus
✨ 基于 ant-design-pro 做一些微小的工作。
Stars: ✭ 88 (-49.43%)
Mutual labels:  antd, ant-design
Antv
Ant Design of Vue.js 2.0
Stars: ✭ 99 (-43.1%)
Mutual labels:  antd, ant-design

A simple plugin to dynamic change ant-design theme whether less or css.

English | 简体中文

After gzip: 42.7kB

This project was initially targeted at 'ant-design', that means it's used in the React project. However, the core style was also applicable to 'ant-design-vue' || 'ant-design-angular'. In addition, for the convenience of one-key and auto use, the color-picker was also packaged into the project, resulting in too large a volume of the project. Aiming at this problem, I develope a new minor version —— mini-dynamic-antd-theme.

🏠 HomePage

Dynamic-Antd-Theme-Demo

🌍 Browser Support

Chrome Edge Firefox IE Safari
Chrome 39.0+ ✔ Edge 12.0+ ✔ Firefox 30.0+ ✔ IE 11+ ✔ Safari 9.1+ ✔

📦 Install

npm install dynamic-antd-theme or yarn add dynamic-antd-theme

🔨 Usage

The best usage of the dynamic-antd-theme is in the common compnent (Layout/Header etc...) of your application.

// Layout.js
...
import DynamicAntdTheme from 'dynamic-antd-theme';
...

<div className='theme-container'>
  <span>Change antd theme: </span>
  <DynamicAntdTheme />
</div>

✨ Props

Props Type Default Description
primaryColor String #1890d5 your antd initial @primary-color
storageName String custom-antd-primary-color the name that is saved in the localStorage
style Object null you can custom the component style simply
placement String bottomRight change the color-picker position, bottom, bottomRight, right, topRight, top, topLeft, left, bottomLeft
themeChangeCallback Func null you can do something use themeColor when themeColor changed.
customCss String '' you can define custom css effect any element.

How to use the primaryColors in customCss?

You can do this using the following four variables(just like scss):

  • $primary-color
  • $primary-hover-color
  • $primary-active-color
  • $primary-shadow-color
const customCss = `
  .ant-btn {
    font-family: fantasy;
  }
  .custom-title {
    color: $primary-color;
  }
  .custom-title:hover {
    color: $primary-hover-color;
    cursor: pointer;
  }
  #custom-id {
    color: $primary-shadow-color;
  }
`;

🌞 Export

export Description
default The component
changeAntdTheme param: (color, options), change the antd theme. The options specific attributes are as follows: - storageName: This can be configured to set storageName when not using picker . - customCss: custom Css

🌰 More Example

Basic Use


<DynamicAntdTheme primaryColor='#77dd66' />

<DynamicAntdTheme storageName='my-custom-define-color' />

<DynamicAntdTheme style={{ display: 'margin: 10px' }} />

function themeChangeCallback (color) {
  document.getElementById('my-header-bar').style.backgroundColor = color;
}

<DynamicAntdTheme themeChangeCallback={this.themeChangeCallback} />

Define Custom CSS

// define custom css
const customCss = `
  .ant-btn {
    font-family: fantasy;
  }
  .custom-title {
    color: $primary-color;
  }
  .custom-title:hover {
    color: $primary-hover-color;
    cursor: pointer;
  }
  #custom-id {
    color: $primary-shadow-color;
  }
`;

<DynamicAntdTheme
  customCss={customCss}
/>

The effects as flow:

No Color-Picker

If u don't need the color-pickermini-dynamic-antd-theme is more suitable for you.

import { generateThemeColor, changeAntdTheme } from 'dynamic-antd-theme';
...

<Button
  onClick={
    () => {
      const color = 'blue';
      changeAntdTheme(color);
    }
  }
>Change Theme</Button>

⚠️ Attention

This solution is easy to use, so it is prone to problems. We hope you can give us timely feedback. For example, if there is a problem with any component, we will fix the updated version as soon as possible.

  • The current version requires your antd version to be lower than v3.19.0

The antd version is higher than v3.19.0 you can also use it, if have some problems remember give me an issue.

  • ...Plugin versions are updated from time to time based on antd (new antd components are updated)

🔗 Changelogs

  • v0.1.3

    Fix the Slider Component.

  • v0.1.4

    Fix repeat insert <style> tag.

  • v0.1.5

    Add placement props, bottom, bottomRight, right, topRight, top, topLeft, left, bottomLeft. Default is bottomRight.

  • v0.1.6

    Add themeChangeCallback props, you can do something use themeColor when themeColor changed.

  • v0.2.0

    Fix ant-design table tr background when cursor hovered.

  • v0.2.4

    Support IE 11+.

  • v0.2.6

    Fix DatePicker current date color.

  • v0.3.0

    Export { generateThemeColor, changeAntdTheme } methods to help the developer who don't need react-colorPicker

  • v0.3.2

    Fix <Button type='danger' /> bug, when hover the font color is primary-color.

  • v0.3.6

    Fix DateRangePicker some bugs.

  • v0.3.7

    Fixtable:hoverin antd^3.20.0+

  • v0.3.8

    Fixcalendersome bugs.

  • v0.3.9

    Fixtree-table-iconbug.

  • v0.4.0

    Add /examples for users to use && look for bugs.

  • v0.5.0

    Add index.d.ts to support Typescript.

  • v0.6.0

    Add customCss Props to support user custom define css.

  • v0.7.0

    Add options in the changeAntdTheme.

  • v0.8.0

    Remove generateThemeColor, now changeAntdTheme first param only need primary color.

🍎 Follow-Up Plan

  • More custom type: border-color, border-radius, etc.

If you're interested in this repository, Fork/PR/Issue all are welcome.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].