diff --git a/.changeset/flex-html-attributes.md b/.changeset/flex-html-attributes.md new file mode 100644 index 0000000000..882594deba --- /dev/null +++ b/.changeset/flex-html-attributes.md @@ -0,0 +1,7 @@ +--- +'@backstage/ui': patch +--- + +Added support for native HTML div attributes on the `Flex` component. + +**Affected components:** Flex diff --git a/packages/ui/report.api.md b/packages/ui/report.api.md index 7e8c8833ee..d584031c7a 100644 --- a/packages/ui/report.api.md +++ b/packages/ui/report.api.md @@ -1214,7 +1214,10 @@ export type FlexOwnProps = { }; // @public (undocumented) -export interface FlexProps extends SpaceProps, FlexOwnProps { +export interface FlexProps + extends SpaceProps, + FlexOwnProps, + Omit, 'children'> { // (undocumented) align?: Responsive<'start' | 'center' | 'end' | 'baseline' | 'stretch'>; // (undocumented) diff --git a/packages/ui/src/components/Flex/Flex.tsx b/packages/ui/src/components/Flex/Flex.tsx index 8700d52681..1e4e4fecb3 100644 --- a/packages/ui/src/components/Flex/Flex.tsx +++ b/packages/ui/src/components/Flex/Flex.tsx @@ -21,7 +21,7 @@ import { FlexDefinition } from './definition'; /** @public */ export const Flex = forwardRef((props, ref) => { - const { ownProps, dataAttributes, utilityStyle } = useDefinition( + const { ownProps, dataAttributes, utilityStyle, restProps } = useDefinition( FlexDefinition, { gap: '4', ...props }, ); @@ -33,6 +33,7 @@ export const Flex = forwardRef((props, ref) => { className={classes.root} style={{ ...utilityStyle, ...ownProps.style }} {...dataAttributes} + {...restProps} > {childrenWithBgProvider} diff --git a/packages/ui/src/components/Flex/types.ts b/packages/ui/src/components/Flex/types.ts index 048d70affc..1c7f887e62 100644 --- a/packages/ui/src/components/Flex/types.ts +++ b/packages/ui/src/components/Flex/types.ts @@ -26,7 +26,10 @@ export type FlexOwnProps = { }; /** @public */ -export interface FlexProps extends SpaceProps, FlexOwnProps { +export interface FlexProps + extends SpaceProps, + FlexOwnProps, + Omit, 'children'> { gap?: Responsive; align?: Responsive<'start' | 'center' | 'end' | 'baseline' | 'stretch'>; justify?: Responsive<'start' | 'center' | 'end' | 'between'>;