![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
emotion-styled-components
Advanced tools
A styled function with automatic filtering of non-standard attributes for your components.
A styled
function with automatic filtering of non-standard attributes base on @emotion/styled
package.
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.
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
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, buttype
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.
See more on emotion.
Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.
Code released under the MIT License.
FAQs
A styled function with automatic filtering of non-standard attributes for your components.
We found that emotion-styled-components demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.