{"id":19290532,"url":"https://github.com/jacob-ebey/styled-components-ts","last_synced_at":"2025-04-09T22:17:35.527Z","repository":{"id":57373288,"uuid":"103740178","full_name":"jacob-ebey/styled-components-ts","owner":"jacob-ebey","description":"Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress and the added benefits of TypeScript 💅","archived":false,"fork":false,"pushed_at":"2018-11-29T19:49:05.000Z","size":124,"stargazers_count":150,"open_issues_count":1,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-09T22:17:30.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"wtfpl","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jacob-ebey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-16T09:14:52.000Z","updated_at":"2024-07-07T16:23:02.000Z","dependencies_parsed_at":"2022-08-29T14:42:20.369Z","dependency_job_id":null,"html_url":"https://github.com/jacob-ebey/styled-components-ts","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-ebey%2Fstyled-components-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-ebey%2Fstyled-components-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-ebey%2Fstyled-components-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jacob-ebey%2Fstyled-components-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jacob-ebey","download_url":"https://codeload.github.com/jacob-ebey/styled-components-ts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248119286,"owners_count":21050755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T22:19:34.373Z","updated_at":"2025-04-09T22:17:35.505Z","avatar_url":"https://github.com/jacob-ebey.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://www.styled-components.com\"\u003e\n  \u003cimg alt=\"styled-components\" src=\"https://raw.githubusercontent.com/styled-components/brand/master/styled-components.png\" height=\"150px\" /\u003e\n\u003c/a\u003e\n\u003cbr /\u003e\n\n[![CircleCI](https://circleci.com/gh/jacob-ebey/styled-components-ts.svg?style=svg)](https://circleci.com/gh/jacob-ebey/styled-components-ts)\n\nVisual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress and the added benefits of TypeScript 💅\n\n```\nnpm install --save styled-components styled-components-ts\n```\n\n## Getting Started\n\n```typescript\n// Import react, styledComponents and styledComponentsTS\nimport * as React from 'react'\nimport styledComponents from 'styled-components'\nimport styledComponentsTS from 'styled-components-ts'\n\n// Create an interface for the component\nexport interface MyImageProps {\n  size: number\n  borderColor?: string\n  borderSize?: number\n}\n\n// Create a styled component with our props interface\nconst MyImage = styledComponentsTS\u003cMyImageProps\u003e(styledComponents.img) `\n  width: ${props =\u003e props.size}px;\n  height: ${props =\u003e props.size}px;\n  border: ${props =\u003e props.borderSize || '4px'} solid ${props =\u003e props.borderColor || 'black'}\n`\n\nexport default MyImage\n\n```\n\nNow we have all the typescript goodies for MyImage like type checking and auto-complete.\n```jsx\nimport MyImage from './MyImage'\n\n\u003cMyImage size={300} borderColor=\"blue\" borderSize={10} /\u003e\n```\n\nWe can also extend our components and add new props with ease.\n```typescript\n// Import react, styledComponents and styledComponentsTS\nimport * as React from 'react'\nimport styledComponents from 'styled-components'\nimport styledComponentsTS from 'styled-components-ts'\n\n// Import our image and it's props\nimport MyImage, { MyImageProps } from './MyImage'\n\n// Create an interface for the component that extends the base image props\nexport interface ExpandedImageProps extends MyImageProps {\n  backgroundColor?: string\n}\n\n// Create a styled component with our props interface that extends MyImage\nconst ExpandedImage = styledComponentsTS\u003cExpandedImageProps\u003e(MyImage.extend)`\n  background-color: ${props =\u003e props.backgroundColor || 'unset'};\n`\n\nexport default ExpandedImage\n```\n\n## Using styled-components v4+?\nIf you're using a version of styled-components greater than `4.0.0` you do not need this library. See below for example usage:\n\n```tsx\nconst Button = styled.div\u003c{ selected?: boolean }\u003e`\n  background: ${props =\u003e props.selected ? 'red' : 'blue'};\n`\n\n// or\ninterface IButton {\n  selected?: boolean\n}\nconst Button = styled.div\u003cIButton\u003e`\n  background: ${props =\u003e props.selected ? 'red' : 'blue'};\n`\n```\n\nFor more information please see https://github.com/styled-components/styled-components\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacob-ebey%2Fstyled-components-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacob-ebey%2Fstyled-components-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacob-ebey%2Fstyled-components-ts/lists"}