Skip to Content
🎉 Coral x Panda has been released 🎉 Read the Migration Guide

Container

Basic Usage

By default the container doesn’t apply any props and therefore acts like an empty div.

import { Container } from '@krakentech/coral'; <Container> <Typography>content</Typography> </Container>

content

viewport

container content

Properties

hasBorderRadius

Apply rounding to the component. The border-radius amount is set to the value defined in theme.borderRadius.base.

<Container hasBorderRadius theme="base100" padding="md"> <Typography color="base500">content</Typography> </Container>

content

fullHeight

Explicitly set the container to be full height. Example includes 150px height as the wrapper.

<div style={{ height: '150' }}> <Container fullHeight> <Typography>content</Typography> </Container> </div>

content

fullWidth

Explicitly set the container to be full width. You might want to do this if you have multiple containers in a Stack that has justifyContent and flexWrap modifiers, but one of them needs to stay full width.

<Stack justifyContent="flex-end" flexWrap="wrap"> <Container> <Typography>Aligned right</Typography> </Container> <Container fullWidth> <Typography>Full width</Typography> </Container> <Container> <Typography>Also aligned right</Typography> </Container> </Stack>

Aligned right

Full width

Also aligned right

margin

The props marginX and marginY override the respective values set with margin. Furthermore, marginLeft, marginRight, marginBottom and marginTop override the respective values set with marginX, marginY or margin. Besides the normal coral spacing values you can also use auto as a value.

<Container margin="xxl" marginX="sm" marginLeft="xs" marginBottom="none"> <Typography>content</Typography> </Container>

content

minWidth

<Stack justifyContent="flex-end" flexWrap="wrap"> <Container> <Typography>Aligned right</Typography> </Container> <Container minWidth={400}> <Typography>400px width</Typography> </Container> <Container> <Typography>Also aligned right</Typography> </Container> </Stack>

Aligned right

400px width

Also aligned right

maxHeight

Note: overflow-y: auto is automatically set

<Container maxHeight={50}> <Typography>Long Running Content</Typography> <Typography>Long Running Content</Typography> <Typography>Long Running Content</Typography> <Typography>Long Running Content</Typography> <Typography>Long Running Content</Typography> <Typography>Long Running Content</Typography> </Container>

Long Running Content

Long Running Content

Long Running Content

Long Running Content

Long Running Content

Long Running Content

minHeight

<Container minHeight={200}> <Typography>content</Typography> </Container>

content

maxWidthPreset

With the maxWidthPreset prop you can define the maximum container width. The container max width values can be configured through the theme configuration.

<Container maxWidthPreset="sm"> <Typography>content</Typography> </Container>

The default presets are:

  • sm 560px
  • md 740px
  • lg 1140px
  • xl 1440px

content

maxWidth

Alternatively, you can also set a custom maxWidth in pixels.

<Container maxWidth={100}> <Typography>content</Typography> </Container>

content

padding

Analogous to the margin, the props paddingX and paddingY override the respective values set with padding. Furthermore, paddingLeft, paddingRight, paddingBottom and paddingTop override the respective values set with paddingX, paddingY or padding.

<Container padding="xxl" paddingX="md" paddingLeft="xs" paddingBottom="sm"> <Typography>content</Typography> </Container>

content

position

<Container position="fixed" top={0} left={0} fullWidth> <Typography textAlign="center">I'm fixed</Typography> </Container>

top / right / bottom / left

<Container position="relative" top={5} right={5} bottom={5} left={5}> <Typography>content</Typography> </Container>

zIndex

<Container zIndex={1}> <Typography>content</Typography> </Container>

theme

You can also apply various themes on the container as shown in the example.

<Container theme="base100" padding="md"> <Typography color="base500">content</Typography> </Container>

content

Responsiveness

<Container padding={{ base: "sm", md: 'xl' }}> <Typography> <span>This container will have sm by default, and xl padding starting at the md breakpoint.</span> </Typography> </Container>

Full API

NameTypeDefault
attributesAttributes & Omit<HTMLAttributes<HTMLElement>, "className" | "style">
themeResponsiveVariant<ConditionalValue<"none" | "base900" | "base100" | "base500"> | undefined>
paddingResponsiveVariant<keyof CoralSpacing>
paddingXResponsiveVariant<keyof CoralSpacing>
paddingYResponsiveVariant<keyof CoralSpacing>
paddingLeftResponsiveVariant<keyof CoralSpacing>
paddingRightResponsiveVariant<keyof CoralSpacing>
paddingTopResponsiveVariant<keyof CoralSpacing>
paddingBottomResponsiveVariant<keyof CoralSpacing>
marginResponsiveVariant<CoralMargin>
marginXResponsiveVariant<CoralMargin>
marginYResponsiveVariant<CoralMargin>
marginLeftResponsiveVariant<CoralMargin>
marginRightResponsiveVariant<CoralMargin>
marginTopResponsiveVariant<CoralMargin>
marginBottomResponsiveVariant<CoralMargin>
widthConditionalValue<SizeToken | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | "4/12" | ... 12 more ... | undefined>
heightConditionalValue<SizeToken | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "screen" | `var(--${string})` | AnyString | ... 5 more ... | undefined>
minWidthConditionalValue<SizeToken | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | "4/12" | ... 12 more ... | undefined>
maxWidthPresetConditionalValue<"none" | "sm" | "md" | "lg" | "xl" | "full"> | undefined
maxWidthConditionalValue<"auto" | SizeToken | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | ... 13 more ... | undefined>
minHeightConditionalValue<SizeToken | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "screen" | `var(--${string})` | AnyString | ... 5 more ... | undefined>
maxHeightConditionalValue<"auto" | SizeToken | "1/2" | "1/3" | "2/3" | "1/4" | "2/4" | "3/4" | "1/5" | "2/5" | "3/5" | "4/5" | "1/6" | "2/6" | "3/6" | "4/6" | "5/6" | "1/12" | "2/12" | "3/12" | ... 13 more ... | undefined>
hasBorderRadiusResponsiveVariant<boolean>
component"symbol" | "object" | "style" | "slot" | "title" | "article" | "button" | "dialog" | "figure" | "form" | "img" | "link" | "main" | "menu" | "menuitem" | "option" | "search" | "switch" | ... 155 more ... | ComponentType<...>
fullHeightResponsiveVariant<boolean>
fullWidthResponsiveVariant<boolean>
positionResponsiveVariant<"static" | "relative" | "absolute" | "sticky" | "fixed">
topConditionalValue<`var(--${string})` | SpacingToken | AnyString | Top<String | Number> | readonly NonNullable<Top<String | Number> | undefined>[] | undefined>
bottomConditionalValue<`var(--${string})` | SpacingToken | AnyString | Bottom<String | Number> | readonly NonNullable<Bottom<String | Number> | undefined>[] | undefined>
leftConditionalValue<`var(--${string})` | SpacingToken | AnyString | Left<String | Number> | readonly NonNullable<Left<String | Number> | undefined>[] | undefined>
zIndexConditionalValue<AnyString | ZIndex | readonly NonNullable<ZIndex | undefined>[] | undefined>
overflowConditionalValue<WithEscapeHatch<OnlyKnown<"overflow", `var(--${string})` | Overflow | readonly string[] | undefined>>> | undefined
overflowXConditionalValue<WithEscapeHatch<OnlyKnown<"overflowX", `var(--${string})` | OverflowX | readonly NonNullable<OverflowX | undefined>[] | undefined>>> | undefined
overflowYResponsiveVariant<ConditionalValue<WithEscapeHatch<OnlyKnown<"overflowY", `var(--${string})` | OverflowY | readonly NonNullable<OverflowY | undefined>[] | undefined>>> | undefined>
transformConditionalValue<AnyString | readonly string[] | Transform | undefined>
childrenReactNode
refRef<HTMLDivElement> | undefined

Allows getting a ref to the component instance. Once the component unmounts, React will set ref.current to null (or call the ref with null if you passed a callback ref).

keyKey | null | undefined
Last updated on