Marigold
v18.0.0-beta.3
Marigold
v18.0.0-beta.3

Application

MarigoldProvider
RouterProvider

Layout

AppShellbeta
Aside
Aspect
Center
Columns
Container
Grid
Inline
Inset
Pagebeta
Panelbeta
Scrollable
Split
Stack
Tiles

Actions

Buttonupdated
ButtonGroupbeta
Link
LinkButton
ToggleButtonbeta

Form

Autocomplete
Calendar
Checkbox
ComboBox
DateField
DatePicker
DateRangePickerbeta
FileField
Form
NumberField
Radio
RangeCalendaralpha
SearchField
SegmentedControlbeta
Select
SelectListupdated
Slider
Switchupdated
TagFieldbeta
TextArea
TextField
TimeField

Collection

Cardupdated
Table
Tag
ActionBaralpha

Navigation

Accordion
Breadcrumbs
Pagination
Sidebarbeta
Tabs
TopNavigationbeta

Overlay

ActionMenualpha
ContextualHelp
Dialog
Drawer
Menuupdated
Toastbeta
Tooltip

Content

Badge
Descriptionalpha
Divider
EmptyStatebeta
Headline
Keyboardbeta
List
Loader
SectionMessage
SVG
Text
TextValuealpha
Titlealpha

Formatters

DateFormat
NumericFormat

Hooks and Utils

cn
cva
extendTheme
parseFormData
useAsyncListData
useLandmark
useListData
useResponsiveValueupdated
useTheme
VisuallyHidden
Components

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

The marigold flower, known for its bright orange and yellow hues, is more than just a vibrant addition to gardens. Marigolds have been used for centuries in traditional medicine for their anti-inflammatory properties. In many cultures, they symbolize positive emotions like warmth and creativity, and are often used in festivals and celebrations. The marigold is also known for its ability to deter garden pests, making it a favorite companion plant for vegetables. Beyond their beauty, these flowers play a role in pollinator gardens, attracting bees and butterflies to enhance biodiversity.
import { Container, Headline, Text } from '@marigold/components';export default () => (  <Container>    <Headline level="3">The marigold flower</Headline>    <Text>      The marigold flower, known for its bright orange and yellow hues, is more      than just a vibrant addition to gardens. Marigolds have been used for      centuries in traditional medicine for their anti-inflammatory properties.      In many cultures, they symbolize positive emotions like warmth and      creativity, and are often used in festivals and celebrations. The marigold      is also known for its ability to deter garden pests, making it a favorite      companion plant for vegetables. Beyond their beauty, these flowers play a      role in pollinator gardens, attracting bees and butterflies to enhance      biodiversity.    </Text>  </Container>);

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.

Font size

The Marigold

Golden petals catch the sun,Blooming bright till day is done.In the garden, standing bold,A gentle spark, the marigold.
Dew drops fall and sparkle clear,Nature's beauty, always near.Orange flames in sunlight hold,Cheerful blooms, the marigold.
import { useState } from 'react';import { Container, Headline, Select, Stack, Text } from '@marigold/components';type FontSizes = 'sm' | 'base' | 'lg';export default () => {  const [fontSize, setFontSize] = useState<FontSizes>('base');  return (    <Stack space={8}>      <Select        label="Font size"        value={fontSize}        onChange={(val: FontSizes) => setFontSize(val)}        width={52}      >        <Select.Option id="sm">Small</Select.Option>        <Select.Option id="base">Default</Select.Option>        <Select.Option id="lg">Large</Select.Option>      </Select>      <Container space={4}>        <Headline level="3">The Marigold</Headline>        <Text fontSize={fontSize}>          Golden petals catch the sun,Blooming bright till day is done.In the          garden, standing bold,A gentle spark, the marigold.        </Text>        <Text fontSize={fontSize}>          Dew drops fall and sparkle clear,Nature's beauty, always near.Orange          flames in sunlight hold,Cheerful blooms, the marigold.        </Text>      </Container>    </Stack>  );};

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.

"Marigolds are perfect for my garden! They’re easy to care for, bright, and keep pests away."
- Jane S., Home Gardener
import { Container, Text } from '@marigold/components';export default () => (  <Container contentLength="short" space={2}>    <Text fontSize="2xl">      "Marigolds are perfect for my garden! They’re easy to care for, bright,      and keep pests away."    </Text>    <Text fontStyle="italic">- Jane S., Home Gardener</Text>  </Container>);

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

In a cozy garden behind an old cottage, a marigold named Sunny grew among daisies and tulips. Her petals were vibrant, glowing in deep shades of orange and yellow. She loved feeling the warmth of the sun as it touched her petals, and she enjoyed the company of her fellow flowers. Butterflies would often visit her, and she would sway gently in the breeze, feeling a sense of peace. Despite all of this, Sunny sometimes felt small compared to the tall sunflowers nearby. They seemed grand, while she was just a splash of color in the corner.
One morning, a little girl named Emma, who lived in the cottage, wandered into the garden feeling sad. Her best friend had moved away, and she needed comfort. When she saw Sunny's glowing petals, Emma smiled for the first time in days. She knelt beside Sunny, touched her petals, and whispered, "You're beautiful." Emma made a small bouquet with Sunny at the center, finding a bit of joy even in her sadness.
After that day, Sunny understood her purpose. It wasn't about being the biggest flower, but about bringing light to others. She had made Emma smile, and that was more important than anything else. Sunny stood tall, proud of her role in the garden—a reminder that even the smallest flowers can have the biggest impact.
import { Columns, Container, Headline, Text } from '@marigold/components';export default () => (  <Container space={6} alignItems="center">    <Headline level="3">Sunny the marigold</Headline>    <Columns columns={[1, 1]} space={8}>      <Text>        In a cozy garden behind an old cottage, a marigold named Sunny grew        among daisies and tulips. Her petals were vibrant, glowing in deep        shades of orange and yellow. She loved feeling the warmth of the sun as        it touched her petals, and she enjoyed the company of her fellow        flowers. Butterflies would often visit her, and she would sway gently in        the breeze, feeling a sense of peace. Despite all of this, Sunny        sometimes felt small compared to the tall sunflowers nearby. They seemed        grand, while she was just a splash of color in the corner.      </Text>      <Text>        One morning, a little girl named Emma, who lived in the cottage,        wandered into the garden feeling sad. Her best friend had moved away,        and she needed comfort. When she saw Sunny's glowing petals, Emma smiled        for the first time in days. She knelt beside Sunny, touched her petals,        and whispered, "You're beautiful." Emma made a small bouquet with Sunny        at the center, finding a bit of joy even in her sadness.      </Text>    </Columns>    <Text>      After that day, Sunny understood her purpose. It wasn't about being the      biggest flower, but about bringing light to others. She had made Emma      smile, and that was more important than anything else. Sunny stood tall,      proud of her role in the garden—a reminder that even the smallest flowers      can have the biggest impact.    </Text>  </Container>);

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:

  • center centers the content, the common choice for a hero section or a centered article on a wide page.
  • right moves 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

Did you know? You can explore, test, and customize props live in Marigold's storybook. Watch the effects they have in real-time!
View Container stories

Container

Prop

Type

Accessibility props (6)

Prop

Type

Related

Building layouts

Learn how to build layouts.
Last update: 11 days ago

Columns

Position content in one row.

Grid

Arrange elements in a grid structure.

On this page

UsageDynamic widthContent lengthComplex layoutAlignmentPropsContainerRelated