Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/styled-components

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/styled-components

TypeScript definitions for styled-components

  • 5.1.34
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1M
increased by10.39%
Maintainers
1
Weekly downloads
 
Created

What is @types/styled-components?

The @types/styled-components package provides TypeScript type definitions for the styled-components library, which is a popular CSS-in-JS library. These type definitions allow TypeScript developers to use styled-components in a type-safe manner, ensuring that styles are applied correctly and that component props are managed according to their expected types.

What are @types/styled-components's main functionalities?

Type-safe styled components

This feature allows developers to create styled components with TypeScript, providing type safety for props. The example shows a button component with a 'primary' prop that changes the background color based on its value.

import styled from 'styled-components';

interface ButtonProps {
  primary: boolean;
}

const Button = styled.button<ButtonProps>`
  background-color: ${props => props.primary ? 'blue' : 'gray'};
  color: white;
  padding: 10px 15px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
`;

Extending styles with TypeScript

This feature demonstrates how to extend an existing styled component while adding additional props with type definitions. The FancyButton extends BasicButton and includes a 'large' prop to adjust the font size.

import styled from 'styled-components';

const BasicButton = styled.button`
  color: white;
  background-color: black;
  padding: 5px 10px;
`;

interface FancyButtonProps {
  large: boolean;
}

const FancyButton = styled(BasicButton)<FancyButtonProps>`
  font-size: ${props => props.large ? '20px' : '12px'};
  border: 2px solid white;
`;

Other packages similar to @types/styled-components

FAQs

Package last updated on 06 Dec 2023

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc