Giter VIP home page Giter VIP logo

styled-wind-docs's Introduction

Styled-wind

A magical implementation of tailwind-like classnames into styled-components.

What is styled wind?

Styled-wind is a CSS-in-JS library, written on top of styled-components. It inherits everything from styled-components and also gives you the flexibility to use tailwind classnames along with styled-components.

Video Introduction:

IMAGE ALT TEXT HERE

A sample Styled-wind component:

import styled from 'styled-wind';

const StyledContainer = styled.div`
    background: red;
    margin-top: 10px;
    # sets text blue
    .text-blue-600; 
    # sets text green for large and xl devices
    .lg:text-green-600; 
    # sets bg yellow on hover
    .hover:bg-yellow; 
    # sets padding top value
    .pt-10; 
    border: 1px solid {props => props.isError ? 'red' : 'green' } 
`


// Alternate syntax
const StyledContainer = styled.div`
    background: red;
    margin-top: 10px;
    # sets text blue
    swind: text-blue-600; 
    # sets text green for large and xl devices
    swind-lg: text-green-600; 
    # sets bg yellow on hover
    swind-hover: bg-yellow; 
    # sets padding top value
    swind: pt-10; 
    border: 1px solid {props => props.isError ? 'red' : 'green' } 
`

Why styled-wind is a good idea?

Styled-wind helps you build responsive web apps very quickly without having a need to write a single line of css. With styled-wind, dynamic styling and handling redundant styles becomes easier and straight-forward. It will also start supporting React Native in near future.

Motivation

Styled-components is one of the most famous CSS-in-JS library and has been favorite styling tool in the React ecosystem. On the other hand, tailwind css has gained a lot of momentum recently because of the ease of use and quick development of responsive web apps. However, there are few practical issues in using tailwind css. This library is an attempt to get the best of both worlds.

See the Quick start guide for more details.

Why styled-wind?

  • Building Responsive sites becomes a lot easier
  • Very small bundle size to use in existing projects
  • 2 minutes migration to use tailwind in a styled-component project
  • Solving the readability issues of tailwind
  • Build reusable components / UI libraries
  • Dynamic styling using props
  • Benefits of tailwind in Component world of React & Styled-components
  • Remembering or writing CSS is not required
  • Tailwind like development for React Native

Prerequisite

Basic knowledge of styled-components and names of class in tailwindcss. The list of tailwind class names can be found here.

Features

  • Zero-CSS
  • Responsive
  • Custom Styling/Theme
  • No class name bugs
  • Development speed
  • Automatic critical CSS
  • Easier maintenance of CSS
  • Automatic vendor prefixing
  • Simple dynamic styling
  • Tailwind is not required

Roadmap/TODO:

Contributions & Suggestions welcome

  • Auto intellisense, syntax highlighting and linting
  • Support for React Native
  • Allowing tailwind classes inside prop's conditions
  • CLI/Context for consuming custom styling
  • Add support for animation classes
  • Optimize the library

Caveats

  • React Native support is not added yet
  • Tailwind classnames aren't supported yet inside keyframes and expressions. However you may still use regular CSS for expressions & keyframes
    // Not allowed. Will be implemented in future
        const StyledComponent = styled.div`
            @keyframes mymove{
                from { .top-10 }
                to { .top-16 }
            }
        `
    
        // Allowed
        const StyledComponent = styled.div`
            @keyframes mymove {
                from {top: 0px;}
                to {top: 200px;}
            }
        `
  • Animation classes aren't supported yet.
  • Custom theme can currently be configured only inside index.html file
  • No support for variants as we find no dominant use case in component world
  • Please report if you happen to find any issues.

Examples

Check out the CodeSandBox to see styled-wind in use.

Community

The creators of the library are always open to discussions/suggestions. Their twitter accounts:

styled-wind-docs's People

Contributors

vilvaathibanpb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.