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

vike-react-styled-components

Package Overview
Dependencies
Maintainers
0
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vike-react-styled-components

[Installation](#installation) [Settings](#settings) [Version history](https://github.com/vikejs/vike-react/blob/main/packages/vike-react-styled-components/CHANGELOG.md) [See also](#see-also)

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
108
Maintainers
0
Weekly downloads
 
Created
Source

vike-react-styled-components

Installation
Settings
Version history
See also


Integrates styled-components to your vike-react app.

Installation

  1. npm install vike-react-styled-components styled-components
    npm install --save-dev babel-plugin-styled-components
    
  2. Extend +config.js:

    // pages/+config.js
    
    import vikeReact from "vike-react/config"
    import vikeReactStyledComponents from "vike-react-styled-components/config"
    
    export default {
      // ...
      extends: [vikeReact, vikeReactStyledComponents]
    }
    
  3. Install babel-plugin-styled-components:

    // vite.config.js
    import { defineConfig } from "vite"
    import react from "@vitejs/plugin-react"
    import vike from "vike/plugin"
    
    export default defineConfig({
      plugins: [
       vike(),
       react({
         babel: {
           plugins: [["babel-plugin-styled-components"]],
         },
       }),
     ],
    });
    
  4. You can now use styled-components at any of your components.

    import { styled } from "styled-components";
    
    const Title = styled.h1`
       font-size: 1.5em;
       text-align: center;
       color: #BF4F74;
     `;
    
    const Wrapper = styled.section`
       padding: 4em;
       background: papayawhip;
     `;
    
    function SomeComponent() {
      return (
        <Wrapper>
         <Title>Hello World!</Title>
       </Wrapper>
      )
    }
    

[!NOTE] The vike-react-styled-components extension requires vike-react.


Settings

vike-react-styled-components provides a configuration +styledComponents for customizing the StyleSheetManager.

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

import type { IStyleSheetManager } from "styled-components"

const styledComponents = {
  styleSheetManager: {
    enableVendorPrefixes: true,
  } as Omit<IStyleSheetManager, "sheet" | "children">,
}

You can remove the styled-components SSR integration from some of your pages:

// pages/about/+styledComponents.js

export const styledComponents = null

For full customization consider ejecting.

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


See also

FAQs

Package last updated on 03 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