Container
Keep content at an optimal reading width.
The <Container> component is designed to limit the width of its content, ensuring an optimal reading experience. By constraining the content width, it helps maintain readability and prevents text from becoming difficult to follow on wide screens.
Usage
The <Container> component is ideal for situations where you need to limit the width of content to ensure better readability and layout consistency. Here are some common use cases where the <Container> component is particularly useful:
- Text-centric pages: Pages that contain mostly text, such as FAQ pages, user guides, or terms of service, benefit from the
<Container>component, as it ensures the text is easy to follow and comfortable to read. - Hero sections: Use the
<Container>for hero banners with headlines and call-to-action buttons. Limiting the width keeps the focus on the main message, avoiding the visual dispersion that comes with overly wide text blocks. - Centering content: The
<Container>is also useful when you need to center content on the page while ensuring it doesn't stretch too far, providing a consistent and polished appearance.
To limit text length, use the <Text> and <Headline> components inside the <Container>. This will automatically adjust the content length to make it easier to read.
The marigold flower
Dynamic width
The width of the <Container> is not fixed. It adjusts based on the font size to ensure the optimal reading length, which is determined by the number of characters per line. This results in the <Container> varying in size depending on its content.
The Marigold
Content length
The length of the content within the <Container> can be adjusted using the contentLength property. This is useful when you want to customize the reading experience based on the type of content.
For example, you might want to shorten the line length for smaller text blocks like quotes or testimonials, while allowing more characters per line for larger bodies of text, such as articles or blog posts. Adjusting contentLength helps to maintain readability and improve the overall user experience depending on the context.
Complex layout
The <Container> component can be combined with other layout components, such as <Column>, to create more complex and cohesive designs. This approach allows you to build immersive layouts while ensuring that text blocks remain readable.
Sunny the marigold
Alignment
Because <Container> caps the width of its content, that content is often narrower than the space the container fills. The alignItems prop controls where the capped content sits within that space.
By default (none) the content sits at the left edge, which suits a normal reading column. Reach for alignItems when a container sits in a wide area and its content should not hug the left:
centercenters the content, the common choice for a hero section or a centered article on a wide page.rightmoves the content to the right edge, for the rarer case where it should sit against the right.
In short, contentLength sets how wide the reading column is, and alignItems sets where that column sits.
Props
Container
Prop
Type
Accessibility props (6)
Prop
Type