npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

emotion-styled-components

v1.0.2

Published

A styled function with automatic filtering of non-standard attributes for your components.

Downloads

258

Readme

emotion-styled-components

Version Badge GZipped size Downloads NPM total downloads

A styled function with automatic filtering of non-standard attributes base on @emotion/styled package.

Motivation

emotion-styled-components is the result of thinking about how we can improve prop forwarding for the @emotion/styled system. In one of our past projects, we used the styled-components system where props forwarding was provided out of the box, but when we switched to @emotion/styled we ran into a problem where some components were generating warnings: Invalid attribute name then we tried to solve this problem. By focusing on the styled-components use case, we were able to solve this problem.

Installation

To use this package you must have installed emotion package

  # with npm
  npm install --save emotion-styled-components @emotion/styled
  # with yarn
  yarn add emotion-styled-components @emotion/styled

Simple Example

If the styled target is a simple element (e.g. styled.div), styled-components passes through any known HTML attribute to the DOM. If it is a custom React component (e.g. styled(MyComponent)), styled-components passes through all props.

This example shows how all props of the Button component are passed on to the DOM node that is mounted, as with React elements.

import styled from 'emotion-styled-components';
import MyButton from '@my-ui-components';

const Button = styled(MyButton)<{ $primary?: boolean; }>`
  background: ${props => props.$primary ? "#BF4F74" : "white"};
  color: ${props => props.$primary ? "white" : "#BF4F74"};
`;

render(
  <div>
    <Button type="button">Normal</Button>
    <Button $primary type="submit">Primary</Button>
  </div>
);

Note how the $primary prop is not passed to the DOM, but type are? The styled function is smart enough to filter non-standard attributes automatically for you.

It also supports all functions coming from emotion by default.

Arguments

See more on emotion.

Contributing

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

License

Code released under the MIT License.