| 1 |
import styles from '@patternfly/react-styles/css/layouts/Stack/stack'; |
| 2 |
import { css } from '@patternfly/react-styles'; |
| 3 |
|
| 4 |
export interface StackProps extends React.HTMLProps<HTMLDivElement> { |
| 5 |
/** Adds space between children. */ |
| 6 |
hasGutter?: boolean; |
| 7 |
/** Content rendered inside the stack layout. */ |
| 8 |
children?: React.ReactNode; |
| 9 |
/** Additional classes added to the stack layout. */ |
| 10 |
className?: string; |
| 11 |
/** Sets the base component to render. Defaults to div. */ |
| 12 |
component?: React.ReactNode; |
| 13 |
} |
| 14 |
|
| 15 |
export const Stack: React.FunctionComponent<StackProps> = ({ |
| 16 |
hasGutter = false, |
| 17 |
className = '', |
| 18 |
children = null, |
| 19 |
component = 'div', |
| 20 |
...props |
| 21 |
}: StackProps) => { |
| 22 |
const Component = component as any; |
| 23 |
return ( |
| 24 |
<Component {...props} className={css(styles.stack, hasGutter && styles.modifiers.gutter, className)}> |
| 25 |
{children} |
| 26 |
</Component> |
| 27 |
); |
| 28 |
}; |
| 29 |
Stack.displayName = 'Stack'; |