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

tailwind-styled-components

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tailwind-styled-components

Create tailwind css react components like styled components with classes name on multiple lines

  • 1.0.4
  • npm
  • Socket score

Version published
Weekly downloads
13K
increased by5.32%
Maintainers
1
Weekly downloads
 
Created
Source

Tailwind-Styled-Component

Create tailwind css react components like styled components with classes name on multiple lines

Install

# using npm
npm i -D tailwind-styled-components

# using yarn
yarn add -D tailwind-styled-components

Usage

Import

import tw from "tailwind-styled-components"

Basic

You can use tailwind-styled-components without using styled components

const Container = tw.div`
    flex
    items-center
    justify-center
    flex-col
    w-full
    bg-indigo-600
`

Will be rendered as

<div class="flex items-center justify-center flex-col w-full bg-indigo-600">
  <!-- children -->
</div>

Extends

const RedContainer = tw(Container)`
    bg-red-600
`

Will be rendered as

<div class="flex items-center justify-center flex-col w-full bg-red-600">
  <!-- children -->
</div>

Overrides the parent background color class

Extends Styled Component

Extend styled components

const StyledComponentWithCustomJs = styled.div`
    filter: blur(1px)
`

const  = tw(StyledComponentWithCustomJs)`
   flex
`

Will be rendered as

<div class="flex" style="filter: blur(1px);">
  <!-- children -->
</div>

Example

import React from "react"
import tw from "tailwind-styled-components"
import styled from "styled-components"

const Container = tw.div`
    flex
    items-center
    justify-center
`

// Create a <Title> react component that renders an <h1> which is
// indigo and sized at 1.125rem
const Title = tw.h1`
  text-lg
  text-indigo-500
`

// Create a <SpecialBlueContainer> react component that renders a <section> with
// a special blue background color
const Container = styled.section`
  background-color: #0366d6;
`

// Create a <Container> react component that extends the SpecialBlueContainer to render
// a tailwind <section> with the special blue background and adds the flex classes 
const Container = tw(SpecialBlueContainer)`
    flex
    items-center
    justify-center
    w-full
`

// Use them like any other React component – except they're styled!
<Container>
  <Title>Hello World, this is my first tailwind styled component!</Title>
</Container>

FAQs

Package last updated on 13 Nov 2020

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