Skip to content

Commit f88e977

Browse files
authored
[labs] Introduce <Box>and <Flex> components (#7595)
1 parent add1fd4 commit f88e977

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2531
-135
lines changed

packages/demo-app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@blueprintjs/core": "workspace:^",
2121
"@blueprintjs/datetime": "workspace:^",
2222
"@blueprintjs/icons": "workspace:^",
23+
"@blueprintjs/labs": "workspace:^",
2324
"@blueprintjs/select": "workspace:^",
2425
"@blueprintjs/table": "workspace:^",
2526
"classnames": "^2.3.1",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* !
2+
* (c) Copyright 2025 Palantir Technologies Inc. All rights reserved.
3+
*/
4+
5+
import { H1 } from "@blueprintjs/core";
6+
import { Box } from "@blueprintjs/labs";
7+
8+
import { ExampleCard } from "./ExampleCard";
9+
10+
export function BoxExample() {
11+
return (
12+
<ExampleCard label="Box">
13+
<Box
14+
asChild={true}
15+
className="box-example"
16+
display="flex"
17+
justifyContent="center"
18+
marginBottom={0}
19+
paddingX={5}
20+
paddingY={2}
21+
>
22+
<H1>BOX</H1>
23+
</Box>
24+
</ExampleCard>
25+
);
26+
}
27+
28+
BoxExample.displayName = "DemoApp.BoxExample";

packages/demo-app/src/examples/ExampleCard.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import classNames from "classnames";
1818

1919
import { Card, H5 } from "@blueprintjs/core";
20+
import { Box, Flex } from "@blueprintjs/labs";
2021

2122
export interface ExampleCardProps {
2223
children: React.ReactNode;
@@ -38,9 +39,15 @@ export const ExampleCard: React.FC<ExampleCardProps> = ({
3839
return (
3940
<div className="example-card-container">
4041
<H5>{label}</H5>
41-
{subLabel && <H5>{subLabel}</H5>}
42+
{subLabel && (
43+
<Box asChild={true} marginYEnd={2}>
44+
<p>{subLabel}</p>
45+
</Box>
46+
)}
4247
<Card className={classNames("example-card", { horizontal })} elevation={0} style={{ width }}>
43-
{children}
48+
<Flex flexDirection={horizontal ? "row" : "column"} gap={2}>
49+
{children}
50+
</Flex>
4451
</Card>
4552
</div>
4653
);

packages/demo-app/src/examples/Examples.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import classNames from "classnames";
1818

1919
import { Classes } from "@blueprintjs/core";
2020

21+
import { BoxExample } from "./BoxExample";
2122
import { BreadcrumbExample } from "./BreadcrumbExample";
2223
import { ButtonExample } from "./ButtonExample";
2324
import { ButtonGroupExample } from "./ButtonGroupExample";
@@ -62,6 +63,7 @@ const ExamplesContainer: React.FC<{ isDark?: boolean }> = ({ isDark = false }) =
6263
const className = isDark ? Classes.DARK : undefined;
6364
return (
6465
<div className={classNames("examples-container", className)}>
66+
<BoxExample />
6567
<BreadcrumbExample />
6668
<ButtonExample />
6769
<ButtonGroupExample />

packages/demo-app/src/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import "@blueprintjs/core/lib/css/blueprint.css";
22
@import "@blueprintjs/datetime/lib/css/blueprint-datetime.css";
33
@import "@blueprintjs/table/lib/css/table.css";
4+
@import "@blueprintjs/labs/lib/css/blueprint-labs.css";
45

56
@import "./styles/examples";
67

packages/demo-app/src/styles/_examples.scss

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,23 +46,6 @@ $dark-intent-danger-text: $red5;
4646

4747
.example-card {
4848
background-color: $light-gray4;
49-
display: flex;
50-
flex-direction: column;
51-
margin-bottom: $pt-spacing * 2;
52-
53-
> :not(:last-child) {
54-
margin-bottom: $pt-spacing * 2;
55-
}
56-
57-
&.horizontal {
58-
flex-direction: row;
59-
justify-content: center;
60-
61-
> :not(:last-child) {
62-
margin-bottom: 0;
63-
margin-right: $pt-spacing * 2;
64-
}
65-
}
6649
}
6750

6851
.tag-container {
@@ -146,3 +129,8 @@ $dark-intent-danger-text: $red5;
146129
.#{$ns}-toast {
147130
margin: ($pt-spacing * 2) 0;
148131
}
132+
133+
.box-example {
134+
background-color: $gray1;
135+
color: $white;
136+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { H4 } from "@blueprintjs/core";
2+
import { Box } from "@blueprintjs/labs";
3+
4+
export default function BoxAsChild() {
5+
return (
6+
<Box asChild={true} marginYEnd={0}>
7+
<H4>This heading has no margin.</H4>
8+
</Box>
9+
);
10+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Box asChild={true} marginYEnd={0}>
2+
<H4>This heading has no margin.</H4>
3+
</Box>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Colors } from "@blueprintjs/core";
2+
import { Box } from "@blueprintjs/labs";
3+
4+
const boxStyle: React.CSSProperties = {
5+
backgroundColor: Colors.BLUE3 + "1A",
6+
borderColor: Colors.BLUE3,
7+
borderRadius: 2,
8+
borderStyle: "dashed",
9+
borderWidth: 1,
10+
};
11+
12+
export default function BoxBasic() {
13+
return (
14+
<Box marginX={3} padding={5} style={boxStyle}>
15+
Content
16+
</Box>
17+
);
18+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Box marginX={3} padding={5}>
2+
Content
3+
</Box>

0 commit comments

Comments
 (0)