Deprecated
This component is deprecated. Please use @atlaskit/primitives/box
Usage
import { Container } from '@loomhq/lens'
<Container>Content</Container>
Border
Use borderSide to specify the border side and it will render with the default border color. To override the default border color use borderColor.
< Arrange gap = " medium " >
< Container padding = " small " borderSide = ' all ' >
with default border
</ Container >
< Container padding = " small " borderSide = ' all ' borderColor = ' primary ' >
with custom border color
</ Container >
< Container padding = " small " borderSide = ' all ' borderColor = ' primary ' borderWidth = " 2px " >
with custom border color
</ Container >
</ Arrange >
Radius
To change border radius, use the radius prop.
< Split gap = " medium " >
{ availableRadii . map ( radius => (
< Container
radius = { radius }
borderSide = " all "
borderWidth = ' 2px '
padding = " large "
>
with radius { radius }
</ Container >
) ) }
</ Split >
Color
Use one of the palette colors .
< Container
borderColor = ' primary '
contentColor = ' primary '
backgroundColor = ' highlight '
borderSide = ' all '
padding = ' medium '
>
Color
</ Container >
Position
< Container
position = " relative "
paddingY = " xlarge "
paddingX = " medium "
borderSide = ' all '
borderWidth = ' 2px '
radius = " medium "
maxWidth = { 36 }
>
< Container
position = " absolute "
top = " xsmall "
right = " xsmall "
>
< IconButton icon = { < SvgClose /> } />
</ Container >
Content
</ Container >
Position and overflow
< Container
borderSide = ' all '
borderWidth = ' 2px '
radius = " medium "
maxWidth = { 36 }
height = { 19 }
overflow = " auto "
>
{ demoText . alphabet . map ( ( letter , index ) => (
< div key = { index } >
< Container
position = " sticky "
top = { 0 }
paddingY = " small "
paddingX = " medium "
borderSide = " bottom "
backgroundColor = " background "
contentColor = " primary "
>
{ letter }
</ Container >
< Container
paddingY = " small "
paddingX = " medium "
contentColor = " bodyDimmed "
>
{ demoText . long }
</ Container >
</ div >
) ) }
</ Container >
Spacing and dimensions
< >
< Container
padding = ' medium '
marginBottom = ' small '
minHeight = { 10 }
borderSide = " all "
>
With padding, marginBottom, and minHeight
</ Container >
< Container
padding = ' medium '
marginLeft = ' xlarge '
maxWidth = { 40 }
borderSide = " all "
>
With padding, marginLeft, and maxWidth
</ Container >
</ >
Spacing and dimensions value types:
See also Responsive props
Semantic spacing value
name unit rem px xsmall0.50.25rem4pxsmall10.5rem8pxmedium21rem16pxlarge31.5rem24pxxlarge52.5rem40pxxxlarge84rem64px
<Container padding="medium" maxWidth="xlarge">Content</Container>
Number value
The number value will be mutiplied by 8.
For example, if we pass 3 it will result in 24px(3*8).
The result is converted to REMs, so the final value is 1.5rem (24/16).
<Container padding="large" maxWidth={20}>Content</Container>
String value
Any valid CSS measurement value, for example, auto, 50%, or 10vw.
<Container padding="1rem" maxWidth="50%">Content</Container>
Semantic HTML
Use htmlTag prop to render a more suited element tag. Only default to div if no other element works better. More about Html5 Semantic Elements .
Responsive props
See available responsive props
For responsive props pass an object where the key is the min-width breakpoint.
prop={{
default: 'xsmall',
xsmall: 'xsmall',
small: 'xsmall',
medium: 'large',
large: 'xlarge',
}}
Custom breakpoint
prop={{
'12em': 'xsmall',
'28em': 'large',
}}
Available breakpoints
breakpoint min width xsmall31em (496px) small48em (768px) medium64em (1024px) large75em (1200px)
Responsive examples
Resize the browser to see the effect.
< Container
borderSide = " all "
padding = { {
default : 'xsmall' ,
xsmall : 'small' ,
small : 'medium' ,
medium : 'large' ,
large : 'xlarge'
} }
marginLeft = { {
medium : 'xlarge'
} }
maxWidth = { {
xsmall : '100%' ,
small : '50%' ,
medium : 25 ,
large : 40
} }
>
Content
</ Container >
Refs
Use the refHandler prop to pass down a function that creates/sets your ref from Container's parent component.
( ) => {
const ref = useRef ( ) ;
const refHandler = ( newRef ) => {
ref . current = newRef ;
}
return (
< >
< Container refHandler = { refHandler } >
< Text > I have a ref value </ Text >
</ Container >
</ >
)
}
Props
borderWidth
string | number
'1px'
htmlTag
| 'div'
| 'header'
| 'article'
| 'section'
| 'nav'
| 'aside'
| 'footer'
| 'main'
| 'span'
| 'form'
| 'table'
'div'
radius
| 'medium'
| 'large'
| 'xlarge'
| 'full'
| 'none'
| '25'
| '50'
| '75'
| '100'
| '150'
| '175'
| '200'
| '250'
| '300'
| 'tile'
| 'round'
borderSide
'all' | 'left' | 'right' | 'top' | 'bottom'
shadow
'small' | 'medium' | 'large'
padding
ResponsiveType
<string | number> | null
paddingX
ResponsiveType
<string | number> | null
paddingY
ResponsiveType
<string | number> | null
paddingLeft
ResponsiveType
<string | number> | null
paddingRight
ResponsiveType
<string | number> | null
paddingTop
ResponsiveType
<string | number> | null
paddingBottom
ResponsiveType
<string | number> | null
margin
ResponsiveType
<string | number> | null
marginX
ResponsiveType
<string | number> | null
marginY
ResponsiveType
<string | number> | null
marginLeft
ResponsiveType
<string | number> | null
marginRight
ResponsiveType
<string | number> | null
marginTop
ResponsiveType
<string | number> | null
marginBottom
ResponsiveType
<string | number> | null
width
ResponsiveType
<string | number>
height
ResponsiveType
<string | number>
minWidth
ResponsiveType
<string | number>
minHeight
ResponsiveType
<string | number>
maxWidth
ResponsiveType
<string | number>
maxHeight
ResponsiveType
<string | number>
top
ResponsiveType
<string | number> | null
bottom
ResponsiveType
<string | number> | null
left
ResponsiveType
<string | number> | null
right
ResponsiveType
<string | number> | null
refHandler
| ((ref: HTMLElement) => void)
| ((ref: HTMLDivElement) => void)
| ((ref: HTMLSpanElement) => void)