{"id":21855680,"url":"https://github.com/dantehemerson/slsx","last_synced_at":"2025-04-14T18:12:26.968Z","repository":{"id":57363414,"uuid":"242480940","full_name":"dantehemerson/slsx","owner":"dantehemerson","description":":nail_care: A tiny utility for constructing React Native Web styles conditionally","archived":false,"fork":false,"pushed_at":"2020-04-04T17:38:07.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T18:12:25.761Z","etag":null,"topics":["classes","clsx","library","react-native","react-native-library","styles","stylesheet"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/dantehemerson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-23T08:19:52.000Z","updated_at":"2020-05-22T19:45:22.000Z","dependencies_parsed_at":"2022-09-16T10:10:52.337Z","dependency_job_id":null,"html_url":"https://github.com/dantehemerson/slsx","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantehemerson%2Fslsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantehemerson%2Fslsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantehemerson%2Fslsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dantehemerson%2Fslsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dantehemerson","download_url":"https://codeload.github.com/dantehemerson/slsx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248933340,"owners_count":21185460,"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":["classes","clsx","library","react-native","react-native-library","styles","stylesheet"],"created_at":"2024-11-28T02:17:21.016Z","updated_at":"2025-04-14T18:12:26.882Z","avatar_url":"https://github.com/dantehemerson.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slsx\n\n\u003e A tiny utility for constructing React Native styles conditionally\n\n\u003e DISCLAIMER: At this moment it only works with `react-native-web`.\n\nThis module is based on [`clsx`](https://github.com/lukeed/clsx).\n\nThis module is available in three formats:\n\n* **ES Module**: `dist/slsx.m.js`\n* **CommonJS**: `dist/slsx.js`\n* **UMD**: `dist/slsx.min.js`\n\n\n## Install\n\n```\nnpm install --save slsx\n```\n\nor\n\n```\nyarn add slsx\n```\n\n\n## Usage\n\n```js\nimport slsx from 'slsx';\n\n// Your styles\nconst styles = StyleSheet.create({\n  foo: {\n    backgroundColor: 'red'\n  },\n  bar: {\n    fontSize: 18\n  },\n  baz: {\n    borderColor: 4\n  },\n  bat: {\n    width: 80\n  },\n  qux: {\n    marginVertical: 20\n  },\n  det: {\n    paddingVertical: 10\n  },\n  met: {\n    paddingHorizontal: 20\n  }\n});\n\n\n// =\u003e  =  'similar to'\n\nslsx(styles.foo, true \u0026\u0026 styles.bar, styles.baz);\n//=\u003e [styles.foo, styles.bar, styles.baz]\n\nslsx({ [styles.foo]: true, [styles.bar]: false, [styles.baz]: isTrue() });\n//=\u003e [styles.foo, styles.baz]\n\n// Objects\nslsx({ [styles.foo]: true }, { [styles.bar]: false }, null);\n//=\u003e [styles.foo]\n\n// Arrays\nslsx([styles.foo, null, false, styles.bar]);\n//=\u003e [styles.foo, styles.bar]\n\n// Arrays (variadic)\nslsx(\n  [styles.foo], \n  ['', null, false, styles.bar], \n  [[styles.baz, [[styles.bat]]]]\n);\n//=\u003e [styles.foo, styles.bar, styles.baz, styles.bat]\n\n// Kitchen sink (with nesting)\nslsx(\n  styles.foo, \n  [\n    1 \u0026\u0026 styles.bar, \n    { \n      [styles.baz]: false, \n      [styles.bat]: null \n    }, \n    [styles.qux, [styles.det]]\n  ], \n  styles.met\n);\n//=\u003e [styles.foo, styles.bar, styles.qux, styles.det, styles.met]\n```\n\nYou can also [test on Codesanbox](https://codesandbox.io/s/slsx-example-mi32b)\n\n## API\n\n### slsx(...input)\nReturns: `number[]`\n\n#### input\nType: `Mixed`\n\nThe `slsx` function can take ***any*** number of arguments, each of which can be an Object, Array, Boolean, or String.\n\n\u003e **Important:** _Any_ values that cannot be transformed into numbers or are negative numbers are discarded!\n\n```js\nslsx(-123, true, false, '', null, undefined, NaN, '-77', 'bar', 'baz');\n//=\u003e ''\n```\n\n## License\n\nMIT © [Dante Calderon](https://dantecalderon.dev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantehemerson%2Fslsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdantehemerson%2Fslsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdantehemerson%2Fslsx/lists"}