{"id":13450612,"url":"https://github.com/style-hook/style-hook","last_synced_at":"2025-03-23T16:31:41.780Z","repository":{"id":35100526,"uuid":"206757393","full_name":"style-hook/style-hook","owner":"style-hook","description":"use css in js with react hook.","archived":true,"fork":false,"pushed_at":"2023-01-05T16:19:34.000Z","size":571,"stargazers_count":15,"open_issues_count":11,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-24T08:16:14.448Z","etag":null,"topics":["css","css-hook","react-hook","react-hooks","style-hook"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/style-hook.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-09-06T09:12:33.000Z","updated_at":"2024-03-01T03:41:44.000Z","dependencies_parsed_at":"2023-01-15T14:00:37.470Z","dependency_job_id":null,"html_url":"https://github.com/style-hook/style-hook","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/style-hook%2Fstyle-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/style-hook%2Fstyle-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/style-hook%2Fstyle-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/style-hook%2Fstyle-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/style-hook","download_url":"https://codeload.github.com/style-hook/style-hook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244236077,"owners_count":20420759,"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":["css","css-hook","react-hook","react-hooks","style-hook"],"created_at":"2024-07-31T07:00:36.681Z","updated_at":"2025-03-23T16:31:41.474Z","avatar_url":"https://github.com/style-hook.png","language":"TypeScript","readme":"![logo](https://avatars1.githubusercontent.com/u/54980825?s=200\u0026v=4)\n\n# style-hook\neasy to write dynamic css\n\n[![Build Status](https://www.travis-ci.org/style-hook/style-hook.svg?branch=master)](https://www.travis-ci.org/style-hook/style-hook)\n[![codecov](https://codecov.io/gh/style-hook/style-hook/branch/master/graph/badge.svg)](https://codecov.io/gh/style-hook/style-hook)\n\n# features\n* use css in react hook\n* easy to get started\n\n# install\nuse npm\n```bash\nnpm i -S style-hook\n```\nor use yarn\n```bash\nyarn add style-hook\n```\n\n## minify css in js (recommend)\nadd babel plugin to your .babelrc\n```json\n{\n  \"plugins\": [\n    \"style-hook/babel\"\n  ]\n}\n```\n\n# usage\n## say hello world to get started\n``` jsx\nimport React from 'react'\nimport { useStyle } from 'style-hook'\nexport default function() {\n  const s = useStyle `\n    font-size: 30px;\n    margin: 20px;\n    color: red;\n  `\n  return \u003cdiv className={s}\u003ehello world\u003c/div\u003e\n}\n```\n\n## a dynamic style example\nall grammars are js, one you need to learn is js.\n``` jsx\nimport React from 'react'\nimport { css, useStyle } from 'style-hook'\nfunction HelloWorld(props) {\n  const cName = useStyle `\n    font-size: 30px;\n    width: ${100/3}%;\n    margin: ${props.margin || 10}px;\n    color: ${props.color};\n    :hover {\n      ${props.hoverStyle}\n    }\n  `\n  return \u003cdiv className={cName}\u003ehello world\u003c/div\u003e\n}\nexport default () =\u003e {\n  const hoverStyle = css `color: red;`\n  return (\n    \u003cHelloWorld color=\"pink\" hoverStyle={hoverStyle} /\u003e\n  )\n}\n```\n\n## more usages\nsee the wiki: [api](https://github.com/style-hook/style-hook/wiki/api) and [F\u0026Q](https://github.com/style-hook/style-hook/wiki/F\u0026Q)\n\n# typescript\nsupport by default\n\n# Highlight and IntelliSense (recommend)\n* [vscode extension](https://marketplace.visualstudio.com/items?itemName=coppy.style-hook)\n\n# support me\nif you like this project, star it, let more one know.\n\n# Credits\n* [styled-components](https://github.com/styled-components/styled-components)\n* [stylis](https://github.com/thysultan/stylis.js)\n","funding_links":[],"categories":["Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyle-hook%2Fstyle-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstyle-hook%2Fstyle-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstyle-hook%2Fstyle-hook/lists"}