Container
Wrap page content in a Box that picks up layout defaults from the active theme.
Container is a client component that renders a Box as a section and applies the theme's container entry before any props you pass. Use it to wrap page content so it picks up the theme's width and padding. It reads the theme through styled-components' ThemeContext.
Workspace settings
Manage your workspace preferences.
Import#
import { Container } from "@reactberry/system/blocks";
Usage#
import { Container, Heading } from "@reactberry/system/blocks";
import { Box, Text } from "@reactberry/system/elements";
export default function SettingsPage() {
return (
<Container>
<Heading title="Settings" subtitle="Manage your workspace preferences." />
<Box skin="surface" shape="rounded" p="m">
<Text>General settings go here.</Text>
</Box>
</Container>
);
}
Examples#
Narrow column#
Override the theme width and padding with maxWidth, mx and p, for example for a form column.
Reset your password
Enter the email address you signed up with and we will send you a reset link.
Different element#
Pass as to render another element, such as an article.
Release 2.4
Projects can now be archived, and exports include comments.
API#
Container#
| Prop | Type | Default | Description |
|---|---|---|---|
children* | React.ReactNode | — | Content rendered inside the container. |
as | React.ElementType | "section" | Element to render. |
All other props are BoxProps and are spread onto the root Box after the theme defaults, so they override them.
Notes#
- Element order of precedence is
as="section", thentheme.container, then your props. The default light theme setscontainer.asto"main", so under that theme the component renders amainelement unless you passas. The default dark theme does not setas, so it renders asection. - The light theme supplies
maxWidth,mx="auto"and responsive padding; the dark theme supplies a background, border, shadow,overflow="auto"and padding. Visual output therefore depends on the active theme. - Must render inside a styled-components
ThemeProvider(for example viaDesignSystemProvider) for the theme defaults to apply. Without a theme it renders a plainsection. - Avoid nesting multiple
Containerinstances when the theme setsas="main", as a document should contain only one visiblemainelement.