0.8.0 âĒ Published 3 years ago
@seed-ui/layout v0.8.0
@seed-ui/layout
Components and style-utilities for creating responsive layouts.
- ð Styled with SCSS. You can import SCSS to use build-in mixins and variables.
- ðŠķ Uses utility-first approach and CSS variables for dynamic styles, so final CSS is much smaller.
- ðŠ Has simple API typed with TypeScript.
- ð Compatible with any UI-kit. This package is responsible only for layouts.
- ð ïļ Includes reusable style-utils for creating new components and styles.
- ð Allows tree-shaking. Unused code can be removed by Webpack or another bundler with tree-shaking support.
Install
yarn add @seed-ui/layoutAPI
Container
Used for sizing and spacings around wrapped components.
import { Container } from '@seed-ui/layout';
function Page() {
return (
<Container
margin={[0, 'auto']}
maxWidth={{
xs: 1,
sm: 540,
md: 720,
lg: 960,
xl: 1140,
xxl: 1320
}}
padding={[0, 2]}
width={1}
>
{/** Inner content **/}
</Container>
)
}Container props
| Name | Description | Default value |
|---|---|---|
| as | ElementType | 'div' |
| height | ResponsiveValue\<Sizing> | - |
| margin | ResponsiveValue\<Spacing> | - |
| maxHeight | ResponsiveValue\<Sizing> | - |
| maxWidth | ResponsiveValue\<Sizing> | - |
| minHeight | ResponsiveValue\<Sizing> | - |
| minWidth | ResponsiveValue\<Sizing> | - |
| padding | ResponsiveValue\<Spacing> | - |
| elementProps | AllHTMLAttributes\<HTMLElement> | - |
Row and Col
Used for grid layouts. Must be used together.
import { Row, Col } from '@seed-ui/layout';
function Page() {
return (
<Row
align="center"
justify={{ xs: 'center', md: 'start' }}
gutter={[3, 4]}
>
<Col xs={6} md={4} xl="auto" >
{/** Inner content **/}
</Col>
<Col xs={6} md={4} xl="auto" >
{/** Inner content **/}
</Col>
</Row>
)
}Row props
| Name | Description | Default value |
|---|---|---|
| as | ElementType | 'div' |
| align | ResponsiveValue\<Align> | - |
| justify | ResponsiveValue\<Justify> | - |
| gutter | ResponsiveValue\<RowGutter> | - |
| elementProps | AllHTMLAttributes\<HTMLElement> | - |
Col props
| Name | Description | Default value |
|---|---|---|
| as | ElementType | 'div' |
| xs | ColSpan | - |
| sm | ColSpan | - |
| md | ColSpan | - |
| lg | ColSpan | - |
| xl | ColSpan | - |
| xxl | ColSpan | - |
| order | ResponsiveValue\<number> | - |
| align | ResponsiveValue\<Align> | '' |
| elementProps | AllHTMLAttributes\<HTMLElement> | - |
Space
Wraps child components into additional divs and creates spacings between them.
import { Space } from '@seed-ui/layout';
function Page() {
return (
<Space
align="start"
justify="cener"
gutter={3}
>
<Button>Button 1</Button>
<Button>Button 2</Button>
</Space>
)
}Space props
| Name | Description | Default value |
|---|---|---|
| as | ElementType | 'div' |
| align | \<Align> | - |
| direction | \<Direction> | - |
| justify | \<Justify> | - |
| gutter | \<Sizing> | - |
| elementProps | AllHTMLAttributes\<HTMLElement> | - |
Bar
Used for sizing, position and offsets.
import { Bar } from '@seed-ui/layout';
function Page() {
return (
<Bar
height={56}
left={0}
position="fixed"
top={0}
width={1}
>
{/** Inner content **/}
</Bar>
)
}Bar props
| Name | Description | Default value |
|---|---|---|
| as | ElementType | 'div' |
| height | ResponsiveValue\<Sizing> | - |
| maxHeight | ResponsiveValue\<Sizing> | - |
| maxWidth | ResponsiveValue\<Sizing> | - |
| minHeight | ResponsiveValue\<Sizing> | - |
| minWidth | ResponsiveValue\<Sizing> | - |
| offset | ResponsiveValue\<Offset> | - |
| position | ResponsiveValue\<Position> | - |
| elementProps | AllHTMLAttributes\<HTMLElement> | - |
Background
Used for background-images.
import { Bar } from '@seed-ui/layout';
function Page() {
return (
<Background
backgroundImage={{
xs: 'pictue.jpg',
md: 'pictue-md.jpg',
xl: 'pictue-xl.jpg',
}}
backgroundRepeat="no-repeat"
backgroundSize="cover"
>
{/** Inner content **/}
</Background>
)
}Background props
| Name | Description | Default value |
|---|---|---|
| as | ElementType | 'div' |
| backgroundImage | ResponsiveValue\<string> | - |
| backgroundPosition | ResponsiveValue\<BackgroundPosition> | - |
| backgroundRepeat | ResponsiveValue\<BackgroundPosition> | - |
| backgroundSize | ResponsiveValue\<BackgroundSize> | - |
| elementProps | AllHTMLAttributes\<HTMLElement> | - |
Hidden
Hides elements according to screen size.
import { Hidden } from '@seed-ui/layout';
function Page() {
return (
<Hidden
lgUp
smDown
>
{/** Inner content **/}
</Hidden>
)
}Hidden props
| Name | Description | Default value |
|---|---|---|
| as | ElementType | 'div' |
| xsDown | boolean | - |
| sm | boolean | - |
| smDown | boolean | - |
| smUp | boolean | - |
| md | boolean | - |
| mdDown | boolean | - |
| mdUp | boolean | - |
| lg | boolean | - |
| lgDown | boolean | - |
| lgUp | boolean | - |
| xl | boolean | - |
| xlDown | boolean | - |
| xlUp | boolean | - |
| xxlUp | boolean | - |
| elementProps | AllHTMLAttributes\<HTMLElement> | - |
Types
| Name | Description |
|---|---|
| Maybe | T | null | undefined |
| Pair | T, T |
| Sizing | number | string |
| Spacing | Sizing | Sizing, Sizing | Sizing, Sizing, Sizing | Sizing, Sizing, Sizing, Sizing |
| Align | 'start' | 'end' | 'center' | 'baseline' | 'stretch' |
| BackgroundXPosition | 'left' | 'center' | 'right' | Sizing |
| BackgroundYPosition | 'top' | 'center' | 'bottom' | Sizing |
| BackgroundPosition | BackgroundXPosition | BackgroundYPosition | BackgroundYPosition, BackgroundXPosition |
| BackgroundRepeatValue | 'no-repeat' | 'repeat' | 'repeat-x' | 'repeat-y' | 'round' | 'space' |
| BackgroundRepeat | BackgroundRepeatValue | Pair\<Omit\<BackgroundRepeatValue, 'repeat-x' | 'repeat-y'>> |
| BackgroundSize | 'contain' | 'cover' | Pair\<Sizing> |
| Direction | 'column' | 'column-reverse' | 'row' | 'row-reverse' |
| Justify | 'start' | 'end' | 'center' | 'space-between' | 'space-around' | 'space-evenly' |
| Offset | Spacing |
| Position | 'absolute' | 'fixed' | 'relative' | 'static' | 'sticky' |
| RowGuter | Sizing | Pair\<Sizing> |
| ResponsiveValueObject | { xs?: Maybe\<T>, sm: Maybe\<T>, md?: Maybe\<T>, lg?: Maybe\<T>, xl?: Maybe\<T>, xxl?: Maybe\<T> } |
| ResponsiveValue | T | ResponsiveValueObject\<T> |
0.8.0
3 years ago
0.7.2
3 years ago
0.7.1
3 years ago
0.7.0
3 years ago
0.6.2
3 years ago
0.5.0
3 years ago
0.6.1
3 years ago
0.6.0
3 years ago
0.4.3
3 years ago
0.4.1
3 years ago
0.4.2
3 years ago
0.3.12
4 years ago
0.4.0
4 years ago
0.3.9
4 years ago
0.3.11
4 years ago
0.3.10
4 years ago
0.3.6
4 years ago
0.3.8
4 years ago
0.3.7
4 years ago
0.3.5
4 years ago
0.3.2
4 years ago
0.3.4
4 years ago
0.3.3
4 years ago
0.3.0
4 years ago
0.3.1
4 years ago
0.2.0
4 years ago
0.1.4
4 years ago
0.1.3
4 years ago
0.1.2
4 years ago
0.1.1
4 years ago
0.1.0
4 years ago
0.0.0
4 years ago
