{"id":16401079,"url":"https://github.com/flodlc/sx-machine","last_synced_at":"2025-07-29T03:06:25.243Z","repository":{"id":63313110,"uuid":"534971438","full_name":"flodlc/sx-machine","owner":"flodlc","description":"Sx-machine provides a Box component for React and its themed SX property.","archived":false,"fork":false,"pushed_at":"2022-11-20T12:46:25.000Z","size":5377,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T13:06:20.673Z","etag":null,"topics":["css","design","react","sx","theme","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/sx-machine","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/flodlc.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":"2022-09-10T11:01:56.000Z","updated_at":"2023-09-15T13:01:21.000Z","dependencies_parsed_at":"2023-01-22T18:00:56.308Z","dependency_job_id":null,"html_url":"https://github.com/flodlc/sx-machine","commit_stats":null,"previous_names":["flodlc/themebox"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/flodlc/sx-machine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flodlc%2Fsx-machine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flodlc%2Fsx-machine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flodlc%2Fsx-machine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flodlc%2Fsx-machine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flodlc","download_url":"https://codeload.github.com/flodlc/sx-machine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flodlc%2Fsx-machine/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267621582,"owners_count":24116900,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["css","design","react","sx","theme","typescript"],"created_at":"2024-10-11T05:29:22.523Z","updated_at":"2025-07-29T03:06:25.215Z","avatar_url":"https://github.com/flodlc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eSx-machine\u003c/h1\u003e\n\u003cp align=\"center\"\u003eFirst class Sx property for React.\u003c/p\u003e\n\n## Sx-machine is a lightweight library that provides a Box component for React and its themed SX property.\n\n### Main features\n\n- Box component for React\n- Sx property with first class typescript support\n- Highly customizable theme provider\n- Reusable components factory\n- Style caching for high performances\n\u003chr\u003e\n\n#### Here is an exemple of usage\n\nhttps://user-images.githubusercontent.com/3781663/199988034-7f4b5e8e-2217-4634-9ab4-9de8740d93c2.mov\n\n## Installation\n\n```\nnpm install sx-machine\n---\nyarn add sx-machine\n```\n\n## Usage\n\n### Basic\n\n```javascript\nconst theme = {\n  ...defaultTheme,\n  colors: {\n    $primary: '#234234',\n  },\n};\n\nconst Exemple = () =\u003e {\n  return (\n    \u003cThemeProvider theme={theme}\u003e\n      \u003cBox sx={{ bg: '$primary', m: 10 }}\u003eContent\u003c/Box\u003e\n    \u003c/ThemeProvider\u003e\n  );\n};\n```\n\n## Theming\n\nSx-machine provides a powerful theming feature.  \nThe default theme includes spaces and breakpoints.\n\n\u003e ### $ prefix\n\u003e\n\u003e It's recommanded to use $ prefixed theme keys to help differenciate theme values from native CSS values\n\n```javascript\nimport { defaultTheme } from 'sx-machine';\n\nconst theme = {\n  ...defaultTheme,\n  colors: {\n    $primary: '#234234',\n    $secondary: '#456456',\n  },\n  shadows: {\n    $1: '0 2px 6px 0 rgba(0, 0, 0, 0.15)',\n    $2: '0 2px 8px 0px rgba(0, 0, 0, 0.13)',\n    $3: '0 2px 12px 1px rgba(0, 0, 0, 0.10)',\n  },\n};\n\nconst App = () =\u003e {\n  return \u003cThemeProvider theme={theme}\u003e...\u003c/ThemeProvider\u003e;\n};\n```\n\n## The `as` attribute\n\nThe Box Component is the primitive component that allows you to access the sx property. By default it renders a div html element.  \nIt accepts a `as` attribute to choose the needed tag.\n\n```javascript\n\u003cBox as=\"a\" href=\"#\" sx={{ color: '$primary' }}\u003e\n  My link\n\u003c/Box\u003e\n```\n\n\u003e Of course, the href attribute type is well inferred from the \"`a`\" tag.  \n\u003e And it works for all tags and Components !\n\n## Reusable components\n\nComponents often need to be reusable and easily customisable with the sx property overriding.  \nLet's create a reusable Button !\n\n```javascript\n// Button.tsx\nimport { createSxComponent } from 'sx-machine';\n\nconst Button: Button = createSxComponent\u003c'div',\n  {\n    children?: React.ReactNode,\n  }\u003e(({ children, sx, ...props }) =\u003e {\n  return (\n    \u003cBox sx={[{ bg: 'green', px: 4, py: 2 }, sx]} {...props}\u003e\n      {children}\n    \u003c/Box\u003e\n  );\n});\n```\n\n```javascript\n// Page.tsx\n\nimport Button from './Button.tsx';\n\nconst Page = () =\u003e {\n  return (\n    \u003cdiv\u003e\n      \u003cButton onClick=() =\u003e {console.log('hey!')}\u003eButton\u003c/Button\u003e\n\n      // Reusable components allows additional style with the sx prop\n      \u003cButton sx={{mt: 4}}\u003eCustom Button\u003c/Button\u003e\n    \u003c/div\u003e\n  );\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflodlc%2Fsx-machine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflodlc%2Fsx-machine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflodlc%2Fsx-machine/lists"}