{"id":20917204,"url":"https://github.com/koheimizuno/grid","last_synced_at":"2025-05-13T12:30:41.983Z","repository":{"id":213295188,"uuid":"729415271","full_name":"koheimizuno/grid","owner":"koheimizuno","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-09T06:41:03.000Z","size":1522,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-28T07:18:36.874Z","etag":null,"topics":["jest","react","react-dom","react-test-renderer","styled-components"],"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/koheimizuno.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-09T06:40:14.000Z","updated_at":"2024-10-18T06:34:04.000Z","dependencies_parsed_at":"2023-12-19T16:42:05.424Z","dependency_job_id":"5a6421c5-a249-4c87-a1cc-c72885e08104","html_url":"https://github.com/koheimizuno/grid","commit_stats":null,"previous_names":["michioyamada/grid","weijiezhang-star/grid","koheimizuno/grid"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koheimizuno%2Fgrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koheimizuno%2Fgrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koheimizuno%2Fgrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koheimizuno%2Fgrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koheimizuno","download_url":"https://codeload.github.com/koheimizuno/grid/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225208385,"owners_count":17438208,"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":["jest","react","react-dom","react-test-renderer","styled-components"],"created_at":"2024-11-18T16:31:09.582Z","updated_at":"2024-11-18T16:31:36.934Z","avatar_url":"https://github.com/koheimizuno.png","language":"JavaScript","readme":"\n\u003cimg src='logo.png' width='128' height='128' /\u003e\n\n# Rebass Grid\n\nResponsive React grid system built with\n[styled-system][], with support for\n[styled-components][] and\n[emotion][] (previously called `grid-styled`)\n\nhttps://rebassjs.org/grid\n\n[![Build Status][badge]][travis]\n[![Downloads][downloads-badge]][npm]\n[![Version][version-badge]][npm]\n\n[badge]: https://flat.badgen.net/travis/rebassjs/grid/master\n[travis]: https://travis-ci.org/rebassjs/grid\n\n[downloads-badge]: https://flat.badgen.net/npm/dw/@rebass/grid\n[version-badge]: https://flat.badgen.net/npm/v/@rebass/grid\n[npm]: https://npmjs.com/package/@rebass/grid\n\n\n## Getting Started\n\n```sh\nnpm i @rebass/grid\n```\n\n```jsx\nimport React from 'react'\nimport { Flex, Box } from '@rebass/grid'\n\nconst App = () =\u003e (\n  \u003cFlex\u003e\n    \u003cBox width={1/2} px={2}\u003e\n      Half width\n    \u003c/Box\u003e\n    \u003cBox width={1/2} px={2}\u003e\n      Half width\n    \u003c/Box\u003e\n  \u003c/Flex\u003e\n)\n```\n\n### Emotion\n\n*Or* for emotion , import `@rebass/grid/emotion`  (uses v10 `@emotion/styled`)\n\n```js\nimport { Flex, Box } from '@rebass/grid/emotion'\n```\n\n## Box\n\nThe Box component handles width, margin and padding.\n\n```jsx\n// Different widths at different breakpoints\n\u003cBox\n  width={[\n    1/2,\n    1/3,\n    1/4,\n    1/6\n  ]}\n/\u003e\n\n// Fixed pixel width\n\u003cBox width={256} /\u003e\n\n// CSS value width\n\u003cBox width='40em' /\u003e\n```\n\n```jsx\n// Padding\n\u003cBox p={2} /\u003e\n\n// Padding top\n\u003cBox pt={2} /\u003e\n\n// Padding bottom\n\u003cBox pb={2} /\u003e\n\n// Padding left\n\u003cBox pl={2} /\u003e\n\n// Padding right\n\u003cBox pr={2} /\u003e\n\n// x-axis padding (left and right)\n\u003cBox px={2} /\u003e\n\n// y-axis padding (top and bottom)\n\u003cBox py={2} /\u003e\n```\n\n```jsx\n// Margin\n\u003cBox m={2} /\u003e\n\n// Margin top\n\u003cBox mt={2} /\u003e\n\n// Margin bottom\n\u003cBox mb={2} /\u003e\n\n// Margin left\n\u003cBox ml={2} /\u003e\n\n// Margin right\n\u003cBox mr={2} /\u003e\n\n// x-axis margin (left and right)\n\u003cBox mx={2} /\u003e\n\n// y-axis margin (top and bottom)\n\u003cBox my={2} /\u003e\n```\n\n```jsx\n// margin auto\n\u003cBox m='auto' /\u003e\n\n// negative margins\n\u003cBox mx={-2} /\u003e\n```\n\n## Props\n\nAll @rebass/grid components use [styled-system][] for style props,\nwhich pick up values from a [theme](#theming) and allow for responsive styles to be passed as [array values](#responsive-styles).\n\n### `width` (number|string|array)\n\nSets width, where numbers `0-1` are percentage values, larger numbers are pixel values, and strings are raw CSS values with units.\nPass an array to set different widths at different breakpoints for\n[responsive styles](#responsive-styles).\n\n### Margin and Padding Props\n\nBoth margin and padding props accept numbers, strings, and arrays as values.\nUsing a number from `0-8` (i.e. an index of `theme.space`) will reference a step on the spacing scale.\nLarger numbers are converted to pixel values.\nNegative Numbers can be used to set negative margins and compensate for grid gutters.\nStrings are passed directly for other valid CSS values.\n\nUse array values to set different margin or padding values per breakpoint for\n[responsive styles](#responsive-styles).\n\nMargin and padding props follow a shorthand syntax for specifying direction.\n\n- `m`:  margin\n- `mt`: margin-top\n- `mr`: margin-right\n- `mb`: margin-bottom\n- `ml`: margin-left\n- `mx`: margin-left and margin-right\n- `my`: margin-top and margin-bottom\n- `p`:  padding\n- `pt`: padding-top\n- `pr`: padding-right\n- `pb`: padding-bottom\n- `pl`: padding-left\n- `px`: padding-left and padding-right\n- `py`: padding-top and padding-bottom\n\n### `flex` (string|array)\n\nSets the `flex` property.\n\n```jsx\n\u003cBox flex='1 1 auto' /\u003e\n```\n\n### `order` (number|string|array)\n\nSets the `order` property.\n\n```jsx\n\u003cBox order={2} /\u003e\n```\n\n### `alignSelf` (string|array)\n\nSets the `align-self` property.\n\n```jsx\n\u003cBox alignSelf='flex-end' /\u003e\n```\n\n### `css` (string|object)\n\nPass styles to styled-components or emotion.\nThis is useful as an escape hatch for one-off styles\nor as a way to extend Rebass Grid components.\n\n```jsx\n\u003cBox\n  bg='blue'\n  css={{\n    borderRadius: '4px'\n  }}\n/\u003e\n```\n\n## `Flex`\n\nThe Flex component extends the Box component and sets display flex.\n\n```jsx\nimport React from 'react'\nimport { Flex, Box } from '@rebass/grid'\n\nconst App = props =\u003e\n  \u003cFlex\u003e\n    \u003cBox\u003eFlex\u003c/Box\u003e\n    \u003cBox\u003eBox\u003c/Box\u003e\n  \u003c/Flex\u003e\n```\n\nIn addition to the Box component props,\nFlex also includes the following:\n\n- `alignItems` (string|array) sets `align-items`\n- `justifyContent` (string|array) sets `justify-content`\n- `flexDirection` (string|array) sets `flex-direction`\n- `flexWrap` (string|array) sets `flex-wrap: wrap`\n\n\n## Responsive Styles\n\nRebass Grid props accept arrays as values for mobile-first responsive styles,\nwhere the first value is for all breakpoints, then each value after is for a min-width\nmedia query from that breakpoint and up.\n\n```jsx\n// 100% below the smallest breakpoint,\n// 50% from the next breakpoint and up,\n// and 25% from the next breakpoint and up\n\u003cBox width={[ 1, 1/2, 1/4 ]} /\u003e\n\n// responsive margin\n\u003cBox m={[ 1, 2, 3, 4 ]} /\u003e\n\n// responsive padding\n\u003cBox p={[ 1, 2, 3, 4 ]} /\u003e\n```\n\n## Extending Components\n\nComponent can be extended with React or using styled-components or emotion.\n\n### InlineFlex\n\n```jsx\nimport React from 'react'\nimport { Flex } from '@rebass/grid'\n\nconst InlineFlex = props =\u003e\n  \u003cFlex\n    {...props}\n    css={{\n      display: 'inline-flex'\n    }}\n  /\u003e\n```\n\n```jsx\n// styled-components example\nimport styled from 'styled-components'\nimport { Flex } from '@rebass/grid'\n\nconst InlineFlex = styled(Flex)`\n  display: inline-flex;\n`\n```\n\n### Max-Width Container\n\n```jsx\nimport React from 'react'\nimport { Box } from '@rebass/grid'\n\nconst Container = props =\u003e\n  \u003cBox\n    {...props}\n    mx='auto'\n    css={{\n      maxWidth: '1024px'\n    }}\n  /\u003e\n```\n\n```js\n// styled-components example\nimport styled from 'styled-components'\nimport { Box } from '@rebass/grid'\n\nconst Container = styled(Box)`\n  max-width: 1024px;\n`\nContainer.defaultProps = {\n  mx: 'auto'\n}\n```\n\n\n### Auto Grid\n\nThis example creates components for a grid with set gutters where the columns expand to fill in the space.\n\n```jsx\n// Example\nimport React from 'react'\nimport { Flex, Box } from '@rebass/grid'\n\nconst Row = props =\u003e (\n  \u003cFlex\n    {...props}\n    mx={-3}\n  /\u003e\n)\n\nconst Column = props =\u003e (\n  \u003cBox\n    {...props}\n    px={3}\n    flex='1 1 auto'\n  /\u003e\n)\n```\n\n## Changing the HTML element\n\nRebass Grid is intended for use with styled-components v4.\nTo change the underlying HTML element, use the styled-components `as` prop.\n\n```jsx\n\u003cBox as='header' /\u003e\n```\n\n*Note:* Previous versions of grid-styled supported an `is` prop, which has been deprecated in favor of the styled-components `as` prop.\n\n## Theming\n\nRebass Grid uses smart defaults, but to customize the values,\nuse the `ThemeProvider` component from styled-components or emotion.\n\n\n```jsx\nimport React from 'react'\nimport { ThemeProvider } from 'styled-components'\nimport { Box } from '@rebass/grid'\n\nconst theme = {\n  space: [ 0, 6, 12, 18, 24 ],\n  breakpoints: [ '32em', '48em', '64em' ]\n}\n\nconst App = () =\u003e (\n  \u003cThemeProvider theme={theme}\u003e\n    \u003cdiv\u003e\n      \u003cBox width={[1, 1/2, 1/4]} px={2}\u003eBox with custom spacing scale and breakpoints\u003c/Box\u003e\n    \u003c/div\u003e\n  \u003c/ThemeProvider\u003e\n)\n```\n\n### Breakpoints\n\nThe Flex and Box components use a mobile-first responsive approach,\nwhere any value set works from that breakpoint and wider.\nBreakpoints are hard-coded to the following min-widths: `40em`, `52em`, `64em`.\n\nTo customize, provide an array of string values that will be converted to media queries.\n\n### Spacing Scale\n\nRebass Grid components' margin and padding props use a 4 step spacing scale to help\nkeep things aligned and keep layouts consistent.\n\nThe default scale is based on an 8px/powers-of-two grid: `[ 0, 4, 8, 16, 32, 64, 128, 256, 512 ]`,\nwhich helps keep spacing consistent and elements aligned even when nesting components.\n\n## Styled Space\n\nRebass Grid also works with the optional [Rebass Space][] package.\n\n```jsx\nimport React from 'react'\nimport { Flex, Box } from '@rebass/grid'\nimport Space from '@rebass/space'\n\nconst App = () =\u003e (\n  \u003cFlex\u003e\n    \u003cSpace mx={3}\u003e\n      \u003ch1\u003eHello\u003c/h1\u003e\n      \u003cBox\u003eBeep\u003c/Box\u003e\n    \u003c/Space\u003e\n  \u003c/Flex\u003e\n)\n```\n\n## Related\n\n- [Rebass Space][]\n- [styled-system][]\n- [@rebass/components][]\n- [Rebass](https://rebassjs.org/)\n- [styled-components][]\n- [emotion][]\n\n[rebass space]: https://github.com/rebassjs/space\n[styled-components]: https://github.com/styled-components/styled-components\n[styled-system]: https://github.com/jxnblk/styled-system\n[emotion]: https://github.com/emotion-js/emotion\n[is-prop]: https://github.com/jxnblk/styled-system/tree/master/system-components#changing-the-underlying-html-element\n[@rebass/components]: https://github.com/rebassjs/components\n\n[MIT License](LICENSE.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoheimizuno%2Fgrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoheimizuno%2Fgrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoheimizuno%2Fgrid/lists"}