Git Product home page Git Product logo

styled-box's Introduction

styled-box

The true css in js, make css as props. lightweight and easy use.

Packages

  • @styled-box/styled the core module, highly inspired by emotion and styled-system.
  • @styled-box/react-primitives a copy from react-native-web, get the base components StyleSheet, View, Text, Image
  • @styled-box/box combine styled, react-primitives, a generic component named Box to support most styles through props.

Examples

the total code can check this index.html, and need run a simple server.

createStyledBox

source

import { createStyledBox } from "https://esm.sh/@styled-box/styled";

const Div = createStyledBox("div");
const App = (props) => <Div marginTop={30} fontSize={40}>{"Hello World!"}</Div>;

result

<div style="margin-top: 30px; font-size: 40px;">
  Hello World!
</div>

Box

source

import Box, { View, Text, Image } from "https://esm.sh/@styled-box/box";

const App = (props) => 
  <Box marginTop={30}>
    <Box fontSize={40}>"Hello World!"</Box>;
  </Box>;

result

automatic generate className, it's benefit by react-native-web

<div class="css-1dbjc4n r-6ity3w">
  <div dir="auto" class="css-901oao r-xb2eav">Hello World!</div>
</div>

Supported Styled Props

reuse modules of styled-system, so same with its api, can check the links.

  • Space       margin, marginTop, marginRight ...
  • Color       color, bg, backgroundColor
  • Typography    fontSize, textAlign, lineHeight ...
  • Layout       width, height, overflow display ...
  • Flexbox      alignItems, alignContent, flexDirection ...
  • Background    backgroundImage, backgroundSize ...
  • Border       border, borderTop, borderRight ...
  • Position      position, zIndex, top, right ...
  • Shadow      textShadow, boxShadow

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.