Skip to main content

Stack : React

Stack serves as a container that serves to create consistent spacing between elements or layouts.

Installation

Before you can start using the @mediahuis/chameleon-react component, you’ll need to install it, for more information check: Getting started for developers.

With that done, you’re now ready to implement the component in your application.

import { Stack, StackItem } from '@mediahuis/chameleon-react';

export default function Example() {
return (
<Stack>
<StackItem>Item 1</StackItem>
<StackItem>Item 2</StackItem>
</Stack>
);
}

Properties

PropertyTypeDefaultRequiredDescription
alignContentString | ResponsiveStrings-NoAligns the content within the container. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content)
alignItemsString | ResponsiveStrings-NoAligns the items within the container. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items)
alignSelfString | ResponsiveStrings-NoDetermines the alignment of the current item in its container. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self)
borderedBoolean-NoA Boolean to determine if the Stack should have a divider between each item.
childrenReactNode-YesThe children to be rendered within the Stack.
flexString | ResponsiveStrings-NoDictates the layout of the children. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/display)
flexBasisString | ResponsiveStrings-NoSpecifies the initial size of a flex item. Accepts CSS-defined values, string values, or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis)
flexDirectionString | ResponsiveStrings'column'NoSpecifies the direction of the flex items. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction)
flexFlowString | ResponsiveStrings-NoShorthand for setting `flexDirection` and `flexWrap`. Accepts CSS-defined values, string values, or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-flow)
flexGrowString | ResponsiveStrings'1'NoDictates the flex item's ability to grow if necessary. Accepts CSS-defined values, string values, or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-grow)
flexShrinkString | ResponsiveStrings-NoDefines the flex item's ability to shrink if necessary. Accepts CSS-defined values, string values, or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-shrink)
flexWrapString | ResponsiveStrings-NoSpecifies whether flex items are forced onto a single line or can wrap onto multiple lines. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap)
gapNumber-NoSets the gap (gutter) between each item in the stack. Accepts scaling tokens as integers.
justifyContentString | ResponsiveStrings-NoDictates the alignment of items along the main axis. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content)
justifySelfString | ResponsiveStrings-NoDetermines the alignment of the current item in its container along the main axis. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self)

StackItem Properties

PropertyTypeDefaultRequiredDescription
alignContentString | ResponsiveStrings-NoAlign content: Specifies the alignment of the content within the container. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content)
alignItemsString | ResponsiveStrings-NoAlign items: Specifies the alignment of the items within the container. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items)
alignSelfString | ResponsiveStrings-NoAlign self: Determines the alignment of the current item in its container. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self)
borderedBoolean-NoWhether the StackItem should have a divider, this can override the parent Stack component.
gapString | ResponsiveStrings-NoSets the gap (gutter) between each item in the stack. Accepts scaling tokens as integers.
flexString | ResponsiveStrings-NoDictates the layout of the children. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/display)
flexBasisString | ResponsiveStrings-NoFlex basis: Specifies the initial size of a flex item. Accepts CSS-defined values, string values, or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-basis)
asElementType-NoRender with a different HTML tag or a different custom component.
childrenReactNode-YesChildren displayed within the Stack, it being HTML or being the StackItem.
classNameString-NoExtend classNames.
flexDirectionString | ResponsiveStrings-NoFlex direction: Specifies the direction of the flex items. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction)
flexFlowString | ResponsiveStrings-NoFlex flow: Shorthand for setting `flexDirection` and `flexWrap`. Accepts CSS-defined values, string values, or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-flow)
flexGrowString | ResponsiveStrings-NoFlex grow: Dictates the flex item's ability to grow if necessary. Accepts CSS-defined values, string values, or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-grow)
flexShrinkString | ResponsiveStrings-NoFlex shrink: Defines the flex item's ability to shrink if necessary. Accepts CSS-defined values, string values, or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-shrink)
flexWrapString | ResponsiveStrings-NoFlex wrap: Specifies whether flex items are forced onto a single line or can wrap onto multiple lines. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap)
justifyContentString | ResponsiveStrings-NoDictates the alignment of items along the main axis. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content)
justifySelfString | ResponsiveStrings-NoDetermines the alignment of the current item in its container along the main axis. Accepts CSS-defined values or a responsive object (xs, sm, md, lg, xl). More info: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self)