zillow / styled-forward-as

Forwarding for the as prop in styled-components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

forwardAs

Forwarding for the as prop in styled-components a la React.forwardRef.

import styled from 'styled-components';
import forwardAs from 'styled-forward-as';

const Button = styled.button`
    /* styles */
`;

const PrefixButton = forwardAs(({ prefix, children, ...rest }, as) => (
    <Button as={as} {...rest}>{prefix}{children}</Button>
))`
    /* styles */
`;

About

Forwarding for the as prop in styled-components


Languages

Language:JavaScript 100.0%