{"id":39206266,"url":"https://github.com/msaktype/picostyle","last_synced_at":"2026-01-26T01:00:58.069Z","repository":{"id":23257784,"uuid":"98557021","full_name":"msaktype/picostyle","owner":"msaktype","description":"Ultra small CSS in JS library in 0.4 KB","archived":true,"fork":false,"pushed_at":"2022-12-10T01:33:00.000Z","size":1723,"stargazers_count":355,"open_issues_count":84,"forks_count":29,"subscribers_count":7,"default_branch":"master","last_synced_at":"2026-01-12T18:51:42.948Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msaktype.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-07-27T16:12:54.000Z","updated_at":"2025-11-19T14:56:05.000Z","dependencies_parsed_at":"2022-09-15T10:01:58.077Z","dependency_job_id":null,"html_url":"https://github.com/msaktype/picostyle","commit_stats":null,"previous_names":["morishitter/picostyle","matype/picostyle","picostyle/picostyle","masaakim/picostyle","msakmrsh/picostyle"],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/msaktype/picostyle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaktype%2Fpicostyle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaktype%2Fpicostyle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaktype%2Fpicostyle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaktype%2Fpicostyle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msaktype","download_url":"https://codeload.github.com/msaktype/picostyle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msaktype%2Fpicostyle/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28763081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T00:37:26.264Z","status":"ssl_error","status_checked_at":"2026-01-26T00:37:25.959Z","response_time":113,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2026-01-17T23:00:20.669Z","updated_at":"2026-01-26T01:00:58.062Z","avatar_url":"https://github.com/msaktype.png","language":"JavaScript","funding_links":[],"categories":["Utilities V1","JavaScript"],"sub_categories":[],"readme":"# Picostyle\n\n[![482 gzip][gzip-badge]][bundlesize]\n[![Build Status][travis-badge]][travis]\n\n[gzip-badge]: https://img.shields.io/badge/minified%20\u0026%20gzipped-482%20B-brightgreen.svg\n[bundlesize]: https://github.com/siddharthkp/bundlesize\n[travis-badge]: https://travis-ci.org/morishitter/picostyle.svg\n[travis]: https://travis-ci.org/morishitter/picostyle\n\nPicostyle is a 0.4 KB CSS-in-JS library for use with frameworks that expose an `h` function.\n\nUpdate: Picostyle is now faster by removing JSON.stringify and supports a new css function that returns a class name for Components that support a class attribute property.\n\n[Try it Online](https://codepen.io/morishitter/pen/aEpGYN?editors=0010)\n\n- **🚀 The smallest CSS-in-JS library**: Only 0.4 KB (minified \u0026 gzipped).\n- **👏 Zero dependencies**: And under 80 LOC.\n- **💅 Styled components**: Gives you a styled component like [styled-components](https://www.styled-components.com/) that y'all love.\n\nCurrently tested with:\n\n- [Preact](https://github.com/developit/preact)\n- [Hyperapp](https://github.com/hyperapp/hyperapp)\n- [Ultradom](https://github.com/jorgebucaran/ultradom)\n\n## Installation\n\nInstall with npm or Yarn.\n\n\u003cpre\u003e\nnpm i \u003ca href=\"https://www.npmjs.com/package/picostyle\"\u003epicostyle\u003c/a\u003e\n\u003c/pre\u003e\n\nThen with a module bundler like [Rollup](https://github.com/rollup/rollup) or [Webpack](https://github.com/webpack/webpack), use as you would anything else.\n\n```js\nimport picostyle from \"picostyle\"\n```\n\nOtherwise, download the [latest release](https://github.com/picostyle/picostyle/releases/latest) or load directly from [unpkg](https://unpkg.com/picostyle) or [jsDelivr](https://cdn.jsdelivr.net/npm/picostyle@latest/dist/picostyle.js).\n```html\n\u003cscript src=\"https://unpkg.com/picostyle\"\u003e\u003c/script\u003e\n```\n\nThen find it in `window.picostyle`.\n\n## Usage\n\nPicostyle will work with any framework that exposes an `h` function. When you pass Picostyle an function `h` it returns a higher order function (HOF) that you can use exactly like the `h` you pass it.\n\nPicostyle can now return an object with the style function and a new css fucntion when the new \"return object\" flag is true\n\n```js\nimport { h } from \"some-framework\"\nimport picostyle from \"picostyle\"\n\nconst style = picostyle(h)\n```\nOr\n```js\nimport { h } from \"some-framework\"\nimport picostyle from \"picostyle\"\n\nconst returnObject = true\nconst { style, css } = picostyle(h, returnObject)\n```\n\nThe HOF accepts a tag name (or an _unstyled_ component) and returns a function that accepts JSON styles.\n\n```js\n// Styled component from tag name\nconst Wrapper = style(\"div\")({\n  minHeight: \"100vh\",\n  background: \"#000\",\n})\n\n// Styling an un-styled component\nconst Component = (props, text) =\u003e h(\"h1\", props, text)\nconst Text = style(Component)({\n  color: \"#fff\",\n})\n\n// Styling a component that supports a class name attribute\nconst Component = (state) =\u003e (\n  h(\"h1\",\n    { \n      class: css( { color: \"#fff\" } )\n    }\n)\n```\n\nIf you want to change the style based on the props, you can do it by passing a function, instead of JSON styles.\n\n```js\n// Here we set the color of the button, based on the color prop\nconst Button = style(\"button\")(props =\u003e ({\n  color: props.color\n}))\n```\n\nYou can also use `@keyframes` animation importing `keyframes` function.\n\n```js\nimport picostyle, { keyframes } from 'picostyle'\n\nconst zoom = keyframes({\n  from: {\n    transform: 'scale(0.5)'\n  },\n  to: {\n    transform: 'scale(2)'\n  },\n})\n\nconst Container = ps('div')({\n  animation: `${zoom} 300ms`,\n})\n```\n\nYou can now use the styled components to build your app.\n\n```js\nconst App = h(\"main\", {}, [\n  Wrapper({}, Text(\"Scoping CSS is hard\")),\n  Wrapper({}, Text(\"Not with styled components!\")),\n  Wrapper({color: 'red'}, Button(\"I'm red!\")),\n])\n```\n\n\nPicostyle transforms any provided JSON styles into plain CSS styles and injects them into a style tag in the head of the document; all under unique style identifiers (USI). Each styled component is given a USI as a class name.\n\nBecause the output is a stylesheet and not inline styles. You can use all valid CSS in your JSON styles. For example:\n\n- Media Queries (`@media (orientation: portrait)`)\n- Pseudo-element and Pseudo-classes (`::before`, `:hover`, `:last-child`).\n- Nested child styles (`\u003e h1`, `\u003e *+*`)\n\n### Preact example\n\n[Get the Code](https://github.com/morishitter/picostyle/tree/master/examples/preact)\n\n```js\nimport picostyle from \"picostyle\"\nimport { h, render } from 'preact';\n\nconst ps = picostyle(h)\n\nconst keyColor = \"#f07\";\n\nconst Text = ps(\"a\")({\n  fontSize: \"64px\",\n  cursor: \"pointer\",\n  color: \"#fff\",\n  padding: \"0.4em\",\n  transition: \"all .2s ease-in-out\",\n  textDecoration: \"none\",\n  \":hover\": {\n    transform: \"scale(1.3)\",\n  },\n  \"@media (max-width: 450px)\": {\n    fontSize: \"32px\",\n  },\n})\n\nconst Wrapper = ps(\"div\")({\n  display: \"flex\",\n  justifyContent: \"center\",\n  alignItems: \"center\",\n  width: \"100vw\",\n  height: \"100vh\",\n  backgroundColor: keyColor,\n})\n\nrender((\n  \u003cWrapper\u003e\n    \u003cText href=\"https://github.com/morishitter/picostyle\"\u003ePicostyle meets Preact\u003c/Text\u003e\n  \u003c/Wrapper\u003e\n), document.body);\n```\n\n\n### Hyperapp Example\n\n[Get the Code](https://github.com/morishitter/picostyle/tree/master/examples/hyperapp)\n\n```js\nimport { h, app } from \"hyperapp\"\nimport picostyle from \"picostyle\"\n\nconst style = picostyle(h)\nconst theme = \"hotpink\" // Try change the theme to white\n\nconst Wrapper = style(\"div\")({\n  display: \"flex\",\n  width: \"100%\",\n  height: \"100vh\",\n  backgroundColor: theme,\n  \"\u003e h1\": { cursor: \"pointer\" }\n})\n\nconst Text = style(\"h1\")({\n  fontSize: \"calc(10px + 5vmin)\",\n  color: theme === \"white\" ? \"black\" : \"white\",\n  margin: \"auto\",\n  transition: \"transform .2s ease-out\",\n  \":hover\": {\n    transform: \"scale(1.2)\",\n  },\n  \"@media (orientation: landscape)\": {\n    fontWeight: \"bold\",\n  },\n})\n\napp({\n  state: {\n    text: \"Picostyle\"\n  },\n  view: (state) =\u003e\n    \u003cWrapper\u003e\n      \u003cText\u003eHello { state.text }\u003c/Text\u003e\n    \u003c/Wrapper\u003e\n})\n```\n\n\n### Ultradom Example\n\n[Get the Code](https://github.com/morishitter/picostyle/tree/master/examples/ultradom)\n\n```js\n/** @jsx */\n\nimport {h, patch} from \"ultradom\"\nimport picostyle from \"picostyle\"\n\nconst ps = picostyle(h)\n\nfunction view(state) {\n  const keyColor = \"#f07\";\n\n  const Text = ps(\"h1\")({\n    fontSize: \"64px\",\n    cursor: \"pointer\",\n    color: \"#fff\",\n    padding: \"0.4em\",\n    transition: \"all .2s ease-in-out\",\n    \":hover\": {\n      transform: \"scale(1.3)\",\n    },\n    \"@media (max-width: 450px)\": {\n      fontSize: \"32px\",\n    },\n  })\n\n  const Wrapper = ps(\"div\")({\n    display: \"flex\",\n    justifyContent: \"center\",\n    alignItems: \"center\",\n    width: \"100vw\",\n    height: \"100vh\",\n    backgroundColor: keyColor,\n  })\n\n  return (\n    \u003cWrapper\u003e\n      \u003cText\u003e{state.trim() === \"\" ? \":)\" : state}\u003c/Text\u003e\n    \u003c/Wrapper\u003e\n  )\n}\n\ndocument.body.appendChild(patch(view(\"Hello, Picostyle\")))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsaktype%2Fpicostyle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsaktype%2Fpicostyle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsaktype%2Fpicostyle/lists"}