@atlaskit/primitives
Version:
Primitives are token-backed low-level building blocks.
106 lines (105 loc) • 3.33 kB
TypeScript
/**
* @jsxRuntime classic
* @jsx jsx
*/
import { type ElementType, type ForwardRefExoticComponent, type MemoExoticComponent, type ReactNode, type RefAttributes } from 'react';
import { type SerializedStyles } from '@emotion/react';
import { type Space } from '../xcss/style-maps.partial';
import type { BasePrimitiveProps } from './types';
export type FlexProps<T extends ElementType = 'div'> = {
/**
* The DOM element to render as the Flex. Defaults to `div`.
*/
as?: 'div' | 'span' | 'ul' | 'ol' | 'li' | 'dl';
/**
* Used to align children along the main axis.
*/
justifyContent?: JustifyContent;
/**
* Used to align children along the cross axis.
*/
alignItems?: AlignItems;
/**
* Represents the space between each child.
*/
columnGap?: Space;
/**
* Represents the space between each child.
*/
gap?: Space;
/**
* Represents the space between each child.
*/
rowGap?: Space;
/**
* Represents the flex direction property of CSS flexbox.
*/
direction?: Direction;
/**
* Represents the flex wrap property of CSS flexbox.
*/
wrap?: Wrap;
/**
* Elements to be rendered inside the Flex.
*/
children: ReactNode;
/**
* The [HTML `id` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id).
*/
id?: string;
/**
* Forwarded ref element.
*/
ref?: React.ComponentPropsWithRef<T>['ref'];
} & BasePrimitiveProps;
type AlignItems = keyof typeof alignItemsMap;
type JustifyContent = keyof typeof justifyContentMap;
type Direction = keyof typeof flexDirectionMap;
type Wrap = keyof typeof flexWrapMap;
declare const justifyContentMap: {
readonly start: SerializedStyles;
readonly center: SerializedStyles;
readonly end: SerializedStyles;
readonly 'space-between': SerializedStyles;
readonly 'space-around': SerializedStyles;
readonly 'space-evenly': SerializedStyles;
readonly stretch: SerializedStyles;
};
declare const flexDirectionMap: {
readonly column: SerializedStyles;
readonly row: SerializedStyles;
};
declare const flexWrapMap: {
readonly wrap: SerializedStyles;
readonly nowrap: SerializedStyles;
};
declare const alignItemsMap: {
readonly start: SerializedStyles;
readonly center: SerializedStyles;
readonly baseline: SerializedStyles;
readonly end: SerializedStyles;
readonly stretch: SerializedStyles;
};
/**
* __Flex__
*
* `Flex` is a primitive component that implements the CSS Flexbox API.
*
* - [Examples](https://atlassian.design/components/primitives/flex/examples)
* - [Code](https://atlassian.design/components/primitives/flex/code)
*
* @example
* ```tsx
* // eslint-disable-next-line @atlaskit/design-system/no-emotion-primitives -- to be migrated to @atlaskit/primitives/compiled – go/akcss
* import { Flex, Box } from '@atlaskit/primitives'
*
* const Component = () => (
* <Flex direction="column">
* <Box padding="space.100" backgroundColor="neutral"></Box>
* <Box padding="space.100" backgroundColor="neutral"></Box>
* </Flex>
* )
* ```
*/
declare const Flex: MemoExoticComponent<ForwardRefExoticComponent<Omit<FlexProps<ElementType>, 'ref'> & RefAttributes<any>>>;
export default Flex;