3.52.6 • Published 12 days ago

reflexy v3.52.6

Weekly downloads
18
License
MIT
Repository
github
Last release
12 days ago

Reflexy npm package

Reflexy is react components library for flexbox and responsive layouts:

  • Flex - flexbox layout with paddings and margins support.
  • styled/Flex - styled version of Flex powered by @mui.

    There are two versions of styled Flex:

    • styled/Flex - powered by modern styling solution by @mui with emotion or styled-components or whatever.
    • styled/jss/Flex - powered by JSS.
  • styled/StyledReflexyWebpackPlugin - webpack plugin for replace regular imports of Flex with styled/Flex. Just import Flex like import { Flex, FlexWithRef } from 'reflexy'; or import { ResponsiveFlex } from 'reflexy/responsive'; and styled/Flex will be used instead.

  • styled/StyledReflexyJssWebpackPlugin - same as styled/StyledReflexyWebpackPlugin but for styled/jss/Flex.
  • FlexWithRef - Flex with forwarded ref.
  • TweakableElementWrapper - Wrapper for react element in order to use it with component prop of Flex.
  • responsive/Responsive - container with breakpoints.
  • responsive/ResponsiveRender - conditional render by breakpoints.
  • responsive/ResponsiveFlex - Like Flex but with breakpoints.
  • responsive/useMediaQuery - React hook for media queries.
  • responsive/MediaQuery - utils for work with media queries and breakpoints.

Custom media queries

Used in CSS.

NameValue
--xxsonly screen and (max-width: 479px)
--xsonly screen and (min-width: 480px) and (max-width: 767px)
--sonly screen and (min-width: 768px) and (max-width: 991px)
--monly screen and (min-width: 992px) and (max-width: 1279px)
--lonly screen and (min-width: 1280px) and (max-width: 1919px)
--xlonly screen and (min-width: 1920px) and (max-width: 2559px)
--xxlonly screen and (min-width: 2560px)

Custom media queries can be used with [postcss-custom-media](https://github.com/postcss/postcss-custom-media#importfrom). Example of configuration with [preset-env](https://preset-env.cssdb.org/):

const exportMediaQueries = require('reflexy/responsive/exportMediaQueries');

module.exports = {
  plugins: {
    'postcss-preset-env': {
      features: {
        'custom-media-queries': {
          importFrom: [{ customMedia: exportMediaQueries() }],
        },
      },
    },
  },
};

Installation

yarn add react reflexy
# or
npm install --save react reflexy

If you use styled version you should also install @mui packages and jss-preset-default if you use JSS version.

Reflexy has own css files so you need provide loader for css files placed in node_modules folder (only if you do not use styled version). With webpack it could be [css-loader](https://github.com/webpack-contrib/css-loader):

{
  test: /\.css$/,
  include: path.join(__dirname, 'node_modules'),
  // or
  include: /reflexy/,
  use: [
    // ...
    { loader: 'css-loader', options: { modules: true } }, // enabled css-modules is necessary
    // ...
  ],
},

Flex

Usage

import { Flex, TweakableElementWrapper } from 'reflexy';

<Flex row justifyContent="center">
  ...
</Flex>

<Flex row justifyContent="center" component={TweakableElementWrapper} element={<button />}>
  ...
</Flex>

<Flex row justifyContent="center" component="button" onClick={...}>
  ...
</Flex>

<Flex row justifyContent="center" componentRef={componentRef}>
  ...
</Flex>

<Flex row justifyContent="center" component={CustomComponent} componentProp1={...} componentProp2={...}>
  ...
</Flex>

<Flex ml pb>
  ...
</Flex>;

Props

Default style is just display: flex.

PropTypeDescription
flex?booleanSets display to flex.
inline?booleanSets display to inline-flex.
row?booleanSets flow-direction to row.
column?booleanSets flow-direction to column. Takes a precedence over row.
reverse?booleanUsed with row or col. Sets flow-direction to column-reverse or row-reverse.
wrap?boolean \| 'inherit' \| 'initial' \| 'unset' \| 'nowrap' \| 'wrap' \| 'wrap-reverse'Sets flex-wrap to corresponding value. Also accepts boolean value: true equals to wrap, false equals to nowrap.
alignContent?'inherit' \| 'initial' \| 'unset' \| 'center' \| 'flex-start' \| 'flex-end' \| 'space-between' \| 'space-around' \| 'space-evenly' \| 'stretch'Sets align-content to corresponding value.
alignItems?'inherit' \| 'initial' \| 'unset' \| 'center' \| 'flex-start' \| 'flex-end' \| 'stretch' \| 'baseline'Sets align-items to corresponding value.
alignSelf?'inherit' \| 'initial' \| 'unset' \| 'center' \| 'flex-start' \| 'flex-end' \| 'stretch' \| 'baseline' \| 'auto' \| 'initial' \| 'inherit'Sets align-self to corresponding value.
justifyContent?'inherit' \| 'initial' \| 'unset' \| 'center' \| 'flex-start' \| 'flex-end' \| 'space-between' \| 'space-around' \| 'space-evenly'Sets justify-content to corresponding value.
center?booleanSets justifyContent and alignItems to center. justifyContent and alignItems take a precedence over center.
basis?'inherit' \| 'initial' \| 'unset' \| 'auto' \| 'content' \| 'number'Sets flex-basis to corresponding value.
grow?0..24 \| booleanSets flex-grow to corresponding value. true is equals to 1, false is equals to 0.
shrink?0..24 \| booleanSets flex-shrink to corresponding value. true is equals to 1, false is equals to 0.
order?numberSets order to corresponding value.
hfill?boolean \| number in range 0.0 to 1.0 inclusiveStretch by horizontal or sets width in percentage (numbers in range 0.0 to 1.0 inclusive).
vfill?boolean \| number in range 0.0 to 1.0 inclusiveStretch by vertical or sets height in percentage (numbers in range 0.0 to 1.0 inclusive).
fill?booleanStretch by vertical and horizontal.
shrinkByContent?booleanSets min-width: 0 and min-height: 0. By default, a flex item cannot be smaller than the size of its content. The initial setting on flex items is min-width: auto and min-height: auto. One way to enable flex items to shrink past their content is to set a flex item to min-width: 0 or min-height: 0.true by default
shrinkWidth?booleanSets min-width to 0. Takes a precedence over shrinkByContent.
shrinkHeight?booleanSets min-height to 0. Takes a precedence over shrinkByContent.
className?stringCSS class name.
style?React.CSSPropertiesInline styles.
component?React.ElementType<P>Sets custom react component as a container. Component must accept className and style through props.
componentRef?React.RefUses when component provides ref.
unit?stringMeasure unit of space
mSize?'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl' \| numberSize of margin
m?typeof mSize \| booleanmargin. Scaling value.
mt?typeof mSize \| booleanmargin-top
mr?typeof mSize \| booleanmargin-right
mb?typeof mSize \| booleanmargin-bottom
ml?typeof mSize \| booleanmargin-left
mx?typeof mSize \| booleanmargin by x axis: margin-left & margin-right
my?typeof mSize \| booleanmargin by y axis: margin-top & margin-bottom
pSize?'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl' \| numberSize of padding
p?typeof pSize \| booleanpadding. Scaling value.
pt?typeof pSize \| booleanpadding-top
pr?typeof pSize \| booleanpadding-right
pb?typeof pSize \| booleanpadding-bottom
pl?typeof pSize \| booleanpadding-left
px?typeof pSize \| booleanpadding by x axis: padding-left & padding-right
py?typeof pSize \| booleanpadding by y axis: padding-top & padding-bottom

Flex Statics

PropTypeDescription
defaultUnitstringMeasure unit of space. Default: rem.
defaultSize'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl'Default: 'm'.
defaultSizesRecord<'xs' \| 's' \| 'm' \| 'l' \| 'xl' \| 'xxl', number>Space sizes. Default: { xs: 0.25, s: 0.5, m: 1, l: 1.5, xl: 2, xxl: 2.5 }.

ResponsiveFlex

Usage

import { ResponsiveFlex } from 'reflexy/responsive';

// `breakpoints` values will override default values for `row` and `order`.
<ResponsiveFlex
  row
  order={1}
  breakpoints={{
    l: { column: true, order: 2 },
    xxs: { alignItems: 'center', order: 4 },
  }}
>
  ...
</ResponsiveFlex>;

Props

All props of [Flex](#Flex) and:

PropTypeDescription
merge?boolean \| BreakpointsMergeTypedown - merge from top to down until current view size. top - merge from down to top until current view size. true treats as down. false - no merge, use only exact breakpoint. Default true.
breakpoints{ [P in ViewSize]?: FlexAllProps<C> }Props per breakpoint.

ViewSize

Same as [Custom media queries](#mq) but names without prefix --.

License

[MIT](https://opensource.org/licenses/mit-license.php)

3.52.6

12 days ago

3.52.5

30 days ago

3.52.4

2 months ago

3.52.3

3 months ago

3.52.2

4 months ago

3.52.1

5 months ago

3.52.0

5 months ago

3.50.1

6 months ago

3.50.0

6 months ago

3.51.0

6 months ago

3.47.1

11 months ago

3.47.2

11 months ago

3.47.3

11 months ago

3.47.4

10 months ago

3.47.5

10 months ago

3.48.0

10 months ago

3.48.1

10 months ago

3.49.0

10 months ago

3.49.1

10 months ago

3.49.2

9 months ago

3.49.3

9 months ago

3.47.0

1 year ago

3.45.1

1 year ago

3.46.0

1 year ago

3.46.1

1 year ago

3.46.2

1 year ago

3.46.3

1 year ago

3.46.4

1 year ago

3.45.0

1 year ago

3.43.0

2 years ago

3.44.0

2 years ago

3.44.1

2 years ago

3.42.5

2 years ago

3.42.6

2 years ago

3.42.3

2 years ago

3.42.0

2 years ago

3.42.1

2 years ago

3.42.2

2 years ago

3.41.8

2 years ago

3.41.4

2 years ago

3.41.5

2 years ago

3.41.6

2 years ago

3.41.7

2 years ago

3.41.1

2 years ago

3.41.2

2 years ago

3.41.3

2 years ago

3.41.0

3 years ago

3.40.0

3 years ago

3.38.0

3 years ago

3.39.0

3 years ago

3.37.6

3 years ago

3.37.5

3 years ago

3.37.1

3 years ago

3.37.2

3 years ago

3.37.3

3 years ago

3.37.4

3 years ago

3.37.0

3 years ago

3.36.1

3 years ago

3.36.0

3 years ago

3.35.0

3 years ago

3.35.1

3 years ago

3.34.2

3 years ago

3.34.1

3 years ago

3.34.0

3 years ago

3.33.6

3 years ago

3.33.7

3 years ago

3.33.3

3 years ago

3.33.4

3 years ago

3.33.5

3 years ago

3.33.2

3 years ago

3.33.1

3 years ago

3.33.0

3 years ago

3.32.0

3 years ago

3.31.0

3 years ago

3.30.0

3 years ago

3.29.0

3 years ago

3.28.2

3 years ago

3.28.1

4 years ago

3.28.0

4 years ago

3.27.0

4 years ago

3.26.0

4 years ago

3.25.0

4 years ago

3.24.0

4 years ago

3.23.2

4 years ago

3.23.1

4 years ago

3.23.0

4 years ago

3.22.4

4 years ago

3.22.3

4 years ago

3.22.5

4 years ago

3.22.2

4 years ago

3.22.1

4 years ago

3.22.0

4 years ago

3.21.0

4 years ago

3.20.2

4 years ago

3.20.1

4 years ago

3.20.0

4 years ago

3.19.1

4 years ago

3.19.0

4 years ago

3.18.0

4 years ago

3.17.1

4 years ago

3.17.0

4 years ago

3.16.0

4 years ago

3.15.1

4 years ago

3.15.0

4 years ago

3.14.0

4 years ago

3.13.0

4 years ago

3.12.6

4 years ago

3.12.3

4 years ago

3.12.5

4 years ago

3.12.4

4 years ago

3.12.2

4 years ago

3.12.1

4 years ago

3.12.0

4 years ago

3.11.3

4 years ago

3.11.2

4 years ago

3.11.0

4 years ago

3.11.1

4 years ago

3.10.0

4 years ago

3.9.2

5 years ago

3.9.1

5 years ago

3.9.0

5 years ago

3.8.0

5 years ago

3.7.0

5 years ago

3.6.0

5 years ago

3.5.1

5 years ago

3.5.0

5 years ago

3.4.1

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.3

5 years ago

3.2.2

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.2

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.20.2

5 years ago

2.20.1

5 years ago

2.20.0

5 years ago

2.19.0

5 years ago

2.18.1

5 years ago

2.18.0

5 years ago

2.17.0

5 years ago

2.16.0

5 years ago

2.15.1

5 years ago

2.15.0

5 years ago

2.14.1

5 years ago

2.14.0

5 years ago

2.12.1

5 years ago

2.12.0

5 years ago

2.11.5

5 years ago

2.11.4

5 years ago

2.11.3

5 years ago

2.11.2

5 years ago

2.11.0

5 years ago

2.10.1

5 years ago

2.10.0

5 years ago

2.9.2

5 years ago

2.9.1

5 years ago

2.9.0

5 years ago

2.8.0

5 years ago

2.7.1

5 years ago

2.7.0

5 years ago

2.6.5

5 years ago

2.6.4

5 years ago

2.6.3

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.0

5 years ago

2.4.7

5 years ago

2.4.6

5 years ago

2.4.5

5 years ago

2.4.4

5 years ago

2.4.3

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.3

5 years ago

2.3.2

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.20.0

6 years ago

1.19.5

6 years ago

1.19.4

6 years ago

1.19.3

6 years ago

1.19.2

6 years ago

1.19.1

6 years ago

1.19.0

6 years ago

1.18.1

6 years ago

1.18.0

6 years ago

1.17.0

6 years ago

1.16.2

6 years ago

1.16.1

6 years ago

1.16.0

6 years ago

1.15.2

6 years ago

1.15.0

6 years ago

1.14.1

6 years ago

1.14.0

6 years ago

1.13.0

6 years ago

1.12.5

6 years ago

1.12.4

6 years ago

1.12.3

6 years ago

1.12.2

7 years ago

1.12.1

7 years ago

1.12.0

7 years ago

1.11.0

7 years ago

1.10.1

7 years ago

1.10.0

7 years ago

1.9.0

7 years ago

1.8.0

7 years ago

1.7.2

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.0

7 years ago

1.5.0

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.2.6

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago