Skip to content

Commit 74237eb

Browse files
authored
[Box] Add support for minHeight and minWidth (#7450)
### WHY are these changes introduced? Some layouts need a minimum height and width and we support `maxHeight` with `Box` so also adding those props. ### WHAT is this pull request doing? - Adds `minHeight` and `minWidth` props <!-- ℹ️ Delete the following for small / trivial changes --> ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) <!-- Give as much information as needed to experiment with the component in the playground. --> <details> <summary>Copy-paste this code in <code>playground/Playground.tsx</code>:</summary> ```jsx import React from 'react'; import {Page} from '../src'; export function Playground() { return ( <Page title="Playground"> {/* Add the code you want to test in here */} </Page> ); } ``` </details> ### 🎩 checklist - [ ] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [ ] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent 31437df commit 74237eb

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

.changeset/funny-hairs-raise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': minor
3+
---
4+
5+
Added support for `minHeight` and `minWidth` on `Box`

polaris-react/src/components/Box/Box.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
--pc-box-border-right: initial;
1212
--pc-box-border-top: initial;
1313
--pc-box-color: initial;
14+
--pc-box-min-height: initial;
15+
--pc-box-min-width: initial;
1416
--pc-box-max-width: initial;
1517
--pc-box-overflow-x: initial;
1618
--pc-box-overflow-y: initial;
@@ -30,6 +32,8 @@
3032
border-right: var(--pc-box-border-right);
3133
border-top: var(--pc-box-border-top);
3234
color: var(--pc-box-color);
35+
min-height: var(--pc-box-min-height);
36+
min-width: var(--pc-box-min-width);
3337
max-width: var(--pc-box-max-width);
3438
overflow-x: var(--pc-box-overflow-x);
3539
overflow-y: var(--pc-box-overflow-y);

polaris-react/src/components/Box/Box.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ export interface BoxProps extends PropsWithChildren {
164164
color?: ColorTokenScale;
165165
/** HTML id attribute */
166166
id?: string;
167+
/** Set minimum height of container */
168+
minHeight?: string;
169+
/** Set minimum width of container */
170+
minWidth?: string;
167171
/** Set maximum width of container */
168172
maxWidth?: string;
169173
/** Clip horizontal content of children */
@@ -204,6 +208,8 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
204208
children,
205209
color,
206210
id,
211+
minHeight,
212+
minWidth,
207213
maxWidth,
208214
overflowX,
209215
overflowY,
@@ -269,6 +275,8 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
269275
'--pc-box-border-radius-top-right': borderRadiuses.topRight
270276
? `var(--p-border-radius-${borderRadiuses.topRight})`
271277
: undefined,
278+
'--pc-box-min-height': minHeight ?? undefined,
279+
'--pc-box-min-width': minWidth ?? undefined,
272280
'--pc-box-max-width': maxWidth ?? undefined,
273281
'--pc-box-overflow-x': overflowX ?? undefined,
274282
'--pc-box-overflow-y': overflowY ?? undefined,

0 commit comments

Comments
 (0)