Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vike-react-antd

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vike-react-antd

Integrates [Ant Design](https://ant.design) to your [`vike-react`](https://vike.dev/vike-react) app.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

vike-react-antd

Integrates Ant Design to your vike-react app.

Installation
Settings
Version history
What it does
See Also


Installation

  1. npm install vike-react-antd antd @ant-design/cssinjs
  2. Extend +config.js:
    // pages/+config.js
    
    import vikeReact from "vike-react/config"
    import vikeReactAntd from "vike-react-antd/config"
    
    export default {
      // ...
      extends: [vikeReact, vikeReactAntd]
    }
    
  3. You can now use Ant Design at any of your components.
    import { Button, Flex } from "antd";
    
    function SomeComponent() {
      return (
        <Flex gap="small" wrap>
         <Button type="primary">Primary Button</Button>
         <Button>Default Button</Button>
       </Flex>
      )
    }
    

[!NOTE] The vike-react-antd extension requires vike-react.


Settings

vike-react-antd provides a configuration +antd for customizing Ant Design Style Compatibility.

// pages/+antd.ts
export { antd }

import { legacyLogicalPropertiesTransformer, px2remTransformer, type StyleProviderProps } from "@ant-design/cssinjs"

const px2rem = px2remTransformer({
  rootValue: 32, // 32px = 1rem; @default 16
})

const antd: Omit<StyleProviderProps, "children" | "cache"> = {
  hashPriority: "high",
  layer: true,
  transformers: [legacyLogicalPropertiesTransformer, px2rem],
}

You can remove the vike-react-antd integration from some of your pages:

// pages/about/+antd.js

export const antd = null

For full customization consider ejecting.

[!NOTE] Consider making a Pull Request before ejecting.


What it does

The vike-react-antd extension allows you to use Ant Design without FOUC.

It collects the page's styles during SSR and injects them in the HTML, ensuring that styles are applied early (before even JavaScript starts loading).

You can learn more at:

For more details, have a look at the source code of vike-react-styled-jsx (which is small).


See also

FAQs

Package last updated on 28 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc