Frame Deprecated
Deprecated
A shorthand over flexbox for positioning elements. Use for one-off arrangements that `HStack` and `VStack` do not cover.
not-compliant
- Overview
- Props
Frame is an abstraction over the FlexBox API to help position elements seamlessly. If you're more comfortable with Flexbox, you can use the VStack or HStack component instead.
Migration Guide
The Frame component is being deprecated in favor of HStack and VStack components. Here are the main action points for migrating your code:
- Identify the Orientation of the Frame: If the Frame component is used to layout elements horizontally, replace it with HStack. If it's used to layout elements vertically, replace it with VStack.
- Handle the Gap: The gap property remains, adjust the value by multiplying by 4 and adding the unit
px. For example,gap={4}becomesgap="$px16". - Migrate the Properties: The Frame component has a different set of properties compared to HStack and VStack. You need to map the old properties to the appropriate
sxcss attribute. For example, thealignmentproperty in Frame corresponds tosx={{alignItems: "xxx"}}in HStack and VStack. Check the alignment and distribution props guide below.
Here are some example of how to migrate:
// Before
<Frame
padding={{ bottom: 4 }}
backgroundColor="blue100"
borderRadius="size16"
direction="row"
alignment="stretch-center"
gap={4}
style={{ minWidth: "30vw", maxWidth: "800px" }}
width="fill"
>
{/* ... */}
</Frame>
// After
<HStack
sx={{
paddingBottom: "$px4",
backgroundColor: "$blue100",
borderRadius: "$px16",
justifyContent: "center",
alignItems: "stretch",
minWidth: "30vw",
maxWidth: 800
width: "100%"
}}
gap="$px16"
>
{/* ... */}
</HStack>
// Before
<Frame alignment="middle-center">
{/* ... */}
</Frame>
// After
<VStack sx={{alignItems: "center", justifyContent: "center"}}>
{/* ... */}
</VStack>
hug and fill value
Frame support the fill and hug value for width and height props. Those are not supported in HStack and VStack
fillvalue becomeswidth="100%"orheight="100%"and according to the direction you can adjust withflexGrow: 1oralignSelf: "stretch"hugbecomeswidth="fit-content"orheight="fit-content"
Alignment and distribution props
Alignment & Distribution props are now redistribute between alignItems and justifyContent in sx prop.
Here is a non exhaustive list of possible value for alignItems and justifyContent according to the alignment and distribution:
| direction | alignment | distribution | alignItems | justifyContent |
|---|---|---|---|---|
| row | top-stretch | space-between | undefined | space-between |
| row | top-stretch | space-around | undefined | space-around |
| row | top-stretch | other | undefined | undefined |
| row | middle-stretch | space-between | center | space-between |
| row | middle-stretch | space-around | center | space-around |
| row | middle-stretch | other | center | undefined |
| row | bottom-stretch | space-between | flex-end | space-between |
| row | bottom-stretch | space-around | flex-end | space-around |
| row | bottom-stretch | other | flex-end | undefined |
| row | stretch-left | space-between | undefined | space-between |
| row | stretch-left | space-around | undefined | space-around |
| row | stretch-left | other | undefined | undefined |
| row | stretch-right | space-between | undefined | space-between |
| row | stretch-right | space-around | undefined | space-around |
| row | stretch-right | other | undefined | undefined |
| row | stretch-center | space-between | undefined | space-between |
| row | stretch-center | space-around | undefined | space-around |
| row | stretch-center | other | undefined | undefined |
| row | top-left | space-between | flex-start | space-between |
| row | top-left | space-around | flex-start | space-around |
| row | top-left | other | flex-start | undefined |
| row | top-center | space-between | flex-start | space-between |
| row | top-center | space-around | flex-start | space-around |
| row | top-center | other | flex-start | undefined |
| row | top-right | space-between | flex-start | space-between |
| row | top-right | space-around | flex-start | space-around |
| row | top-right | other | flex-start | undefined |
| row | middle-left | space-between | center | space-between |
| row | middle-left | space-around | center | space-around |
| row | middle-left | other | center | undefined |
| row | middle-center | space-between | center | space-between |
| row | middle-center | space-around | center | space-around |
| row | middle-center | other | center | center |
| row | middle-right | space-between | center | space-between |
| row | middle-right | space-around | center | space-around |
| row | middle-right | other | center | undefined |
| row | bottom-left | space-between | flex-end | space-between |
| row | bottom-left | space-around | flex-end | space-around |
| row | bottom-left | other | flex-end | undefined |
| row | bottom-center | space-between | flex-end | space-between |
| row | bottom-center | space-around | flex-end | space-around |
| row | bottom-center | other | flex-end | undefined |
| row | bottom-right | space-between | flex-end | space-between |
| row | bottom-right | space-around | flex-end | space-around |
| row | bottom-right | other | flex-end | undefined |
| not row | top-stretch | space-between | undefined | space-between |
| not row | top-stretch | space-around | undefined | space-around |
| not row | top-stretch | other | undefined | undefined |
| not row | middle-stretch | space-between | undefined | space-between |
| not row | middle-stretch | space-around | undefined | space-around |
| not row | middle-stretch | other | undefined | undefined |
| not row | bottom-stretch | space-between | flex-end | space-between |
| not row | bottom-stretch | space-around | flex-end | space-around |
| not row | bottom-stretch | other | flex-end | undefined |
| not row | stretch-left | space-between | undefined | space-between |
| not row | stretch-left | space-around | undefined | space-around |
| not row | stretch-left | other | undefined | undefined |
| not row | stretch-right | space-between | undefined | space-between |
| not row | stretch-right | space-around | undefined | space-around |
| not row | stretch-right | other | undefined | undefined |
| not row | stretch-center | space-between | center | space-between |
| not row | stretch-center | space-around | center | space-around |
| not row | stretch-center | other | center | undefined |
| not row | top-left | space-between | flex-start | space-between |
| not row | top-left | space-around | flex-start | space-around |
| not row | top-left | other | flex-start | undefined |
| not row | top-center | space-between | center | space-between |
| not row | top-center | space-around | center | space-around |
| not row | top-center | other | center | undefined |
| not row | top-right | space-between | flex-end | space-between |
| not row | top-right | space-around | flex-end | space-around |
| not row | top-right | other | flex-end | undefined |
| not row | middle-left | space-between | flex-start | space-between |
| not row | middle-left | space-around | flex-start | space-around |
| not row | middle-left | other | flex-start | undefined |
| not row | middle-center | space-between | center | space-between |
| not row | middle-center | space-around | center | space-around |
| not row | middle-center | other | center | center |
| not row | middle-right | space-between | flex-end | space-between |
| not row | middle-right | space-around | flex-end | space-around |
| not row | middle-right | other | flex-end | undefined |
| not row | bottom-left | space-between | flex-start | space-between |
| not row | bottom-left | space-around | flex-start | space-around |
| not row | bottom-left | other | flex-start | undefined |
| not row | bottom-center | space-between | center | space-between |
| not row | bottom-center | space-around | center | space-around |
| not row | bottom-center | other | center | flex-end |
| not row | bottom-right | space-between | flex-end | space-between |
| not row | bottom-right | space-around | flex-end | space-around |
| not row | bottom-right | other | flex-end | flex-end |
Frame props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| alignment | Alignmentundefined | How children are aligned in the parent Frame. - `stretch` props make children without fixed dimensions to stretch to the size of the parent in the orthogonal direction (horizontal for `column`, vertical for `row`) - ⚠️ Alignment `top-left` doesn't work under `ScrollView`. Please use `top-stretch` instead. (see [this](https://github.com/facebook/react-native/issues/31555)) | ||
| backgroundColor | 94 possibilities"pink500""pink700""pink900""grey200""grey500""grey600""blue700""grey50""grey100""grey200HighContrast""grey300""grey400""grey600HighContrast""grey700""grey800""grey900""blue50""blue100""blue300""blue500""blue900""teal50""teal100""teal300""teal500""teal700""teal900""pink50""pink100""pink300""pink500HighContrast""pink700HighContrast""pink900HighContrast""yellow50""yellow100""yellow300""yellow500""yellow700""whiteAlpha100""whiteAlpha300""whiteAlpha400""whiteAlpha500""whiteAlpha600""whiteAlpha700""whiteAlpha800""whiteAlpha900""white""black""fluoYellow""cream""lightCream""warning""transparent""action""action50""action100""action300""action500""action700""action900""positive""positive50""positive100""positive300""positive500""positive700""positive900""warning50""warning100""warning300""warning500""warning500HighContrast""warning700""warning700HighContrast""warning900""warning900HighContrast""negative""negative50""negative100""negative300""negative500""negative500HighContrast""negative700""negative700HighContrast""negative900""negative900HighContrast""blue""pink""brand""grey""facebook""twitter""linkedin"undefined | |||
| borderColor | 94 possibilities"pink500""pink700""pink900""grey200""grey500""grey600""blue700""grey50""grey100""grey200HighContrast""grey300""grey400""grey600HighContrast""grey700""grey800""grey900""blue50""blue100""blue300""blue500""blue900""teal50""teal100""teal300""teal500""teal700""teal900""pink50""pink100""pink300""pink500HighContrast""pink700HighContrast""pink900HighContrast""yellow50""yellow100""yellow300""yellow500""yellow700""whiteAlpha100""whiteAlpha300""whiteAlpha400""whiteAlpha500""whiteAlpha600""whiteAlpha700""whiteAlpha800""whiteAlpha900""white""black""fluoYellow""cream""lightCream""warning""transparent""action""action50""action100""action300""action500""action700""action900""positive""positive50""positive100""positive300""positive500""positive700""positive900""warning50""warning100""warning300""warning500""warning500HighContrast""warning700""warning700HighContrast""warning900""warning900HighContrast""negative""negative50""negative100""negative300""negative500""negative500HighContrast""negative700""negative700HighContrast""negative900""negative900HighContrast""blue""pink""brand""grey""facebook""twitter""linkedin"undefined | grey500 | ||
| borderRadius | 11 possibilities"size12""size16""size20""size24""size32""size40""size48""size4""size8""sizeInfinite"undefined | |||
| borderType | "none""dashed""solid"undefined | none | ||
| borderWidth | numberundefined | |||
| direction | Directionundefined | column | ||
| distribution | Distributionundefined | packed | ||
| gapInBaseNumber | numberundefined | 0 | Gap between elements within a Frame. | |
| height | Sizingundefined | Specify `fill` for a full-width, `hug` to adapt width to content, or any fixed `number` (in px) Don't fill this prop to let flexbox handle it | ||
| hideDown | 8 possibilities"xs""sm""md""lg""vs""xl""xxl"undefined | |||
| hideUp | 8 possibilities"xs""sm""md""lg""vs""xl""xxl"undefined | |||
| marginInBaseNumber | PaddingOrMarginundefined | Pass a ```number``` for uniform margin or a Margin object ```{horizontal:? number, vertical: number}``` for symmetric margin. | ||
| overflowX | OverflowXundefined | |||
| overflowY | OverflowYundefined | |||
| paddingInBaseNumber | PaddingOrMarginundefined | Pass a ```number``` for uniform padding or a Padding object ```{horizontal:? number, vertical: number}``` for symmetric padding. | ||
| parentFrameDirection | Directionundefined | |||
| width | Sizingundefined | Specify `fill` for a full-width, `hug` to adapt width to content, or any fixed `number` (in px) Don't fill this prop to let flexbox handle it |
Deprecated props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| className | stringundefined | use `sx` instead | ||
| gap | numberundefined | use gapInBaseNumber instead | ||
| margin | PaddingOrMarginundefined | use marginInBaseNumber instead | ||
| padding | PaddingOrMarginundefined | use paddingInBaseNumber instead |
Undocumented props
| Name | Type | Default Value | Description | Usage count |
|---|---|---|---|---|
| css | any | |||
| data-step | any | |||
| id | any | |||
| onClick | any | |||
| onMouseDown | any | |||
| onMouseEnter | any | |||
| onMouseLeave | any | |||
| onMouseOut | any | |||
| onMouseOver | any | |||
| ref | any | |||
| role | any | |||
| style | any | |||
| title | any |