Skip to content

nico2che/preact-styled-components

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

preact-styled-components

This is a fork from stereobooster's unstyled-components as I wish I could have found it adapted for preact.

This is not styled-components.

Installation

npm i preact-styled-components

yarn add preact-styled-components

Example

import { h } from "preact";
import isPropValid from "@emotion/is-prop-valid";
import { styled, ThemeProvider } from "preact-styled-components";

const Title = styled("h1", {
  shouldForwardProp: prop => isPropValid(prop) && prop !== "color"
})(props => ({
  color: "hotpink",
  background: props.theme.background
}));

export const StyledTest = () => (
  <ThemeProvider theme={{ background: "#000" }}>
    <Title color="lightgreen">This is lightgreen.</Title>
  </ThemeProvider>
);

Why?

...

About

styled-components based on React's style prop

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%