Skip to content

Commit b721655

Browse files
liubrandonBrandon Liuclaudesvc-changelogggdouglas
authored
Feature/divider compact prop (#7501)
Co-authored-by: Brandon Liu <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: svc-changelog <[email protected]> Co-authored-by: Greg Douglas <[email protected]>
1 parent 1782045 commit b721655

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

packages/core/src/components/divider/_divider.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ $divider-margin: $pt-grid-size * 0.5 !default;
1515
.#{$ns}-dark & {
1616
border-color: $pt-dark-divider-white;
1717
}
18+
19+
.#{$ns}-compact {
20+
margin: 0;
21+
}
1822
}

packages/core/src/components/divider/divider.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ Use **Divider** to separate blocks of content within a page or container. By def
1616

1717
@reactCodeExample DividerBasicExample
1818

19+
@## Compact
20+
21+
The `compact` prop removes the margin from the divider, making it flush with adjacent content.
22+
23+
```tsx
24+
<Divider compact />
25+
```
26+
1927
@## Vertical
2028

2129
When used inside a flex container, **Divider** adapts to the layout's direction. It becomes a vertical divider when placed between flex items.

packages/core/src/components/divider/divider.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@
1717
import classNames from "classnames";
1818
import * as React from "react";
1919

20-
import { DIVIDER } from "../../common/classes";
20+
import { Classes } from "../../common";
2121
import { DISPLAYNAME_PREFIX, type Props } from "../../common/props";
2222

2323
export interface DividerProps extends Props, React.HTMLAttributes<HTMLElement> {
24+
/**
25+
* If true, makes the Divider flush with adjacent content.
26+
*
27+
* @default false
28+
*/
29+
compact?: boolean;
30+
2431
/**
2532
* HTML tag to use for element.
2633
*
@@ -37,8 +44,8 @@ export interface DividerProps extends Props, React.HTMLAttributes<HTMLElement> {
3744
*
3845
* @see https://blueprintjs.com/docs/#core/components/divider
3946
*/
40-
export const Divider: React.FC<DividerProps> = ({ className, tagName = "div", ...htmlProps }) => {
41-
const classes = classNames(DIVIDER, className);
47+
export const Divider: React.FC<DividerProps> = ({ className, compact = false, tagName = "div", ...htmlProps }) => {
48+
const classes = classNames(Classes.DIVIDER, { [Classes.COMPACT]: compact }, className);
4249
return React.createElement(tagName, {
4350
...htmlProps,
4451
className: classes,

packages/docs-app/src/examples/core-examples/dividerPlaygroundExample.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ import { Example, type ExampleProps, handleBooleanChange } from "@blueprintjs/do
2121

2222
export const DividerPlaygroundExample: React.FC<ExampleProps> = props => {
2323
const [vertical, setVertical] = React.useState(false);
24+
const [compact, setCompact] = React.useState(false);
2425

2526
const options = (
2627
<>
2728
<H5>Example props</H5>
2829
<Switch checked={vertical} label="Vertical" onChange={handleBooleanChange(setVertical)} />
30+
<Switch checked={compact} label="Compact" onChange={handleBooleanChange(setCompact)} />
2931
</>
3032
);
3133

@@ -34,10 +36,10 @@ export const DividerPlaygroundExample: React.FC<ExampleProps> = props => {
3436
<ButtonGroup vertical={vertical} variant="minimal">
3537
<Button text="File" />
3638
<Button text="Edit" />
37-
<Divider />
39+
<Divider compact={compact} />
3840
<Button text="Create" />
3941
<Button text="Delete" />
40-
<Divider />
42+
<Divider compact={compact} />
4143
<Button icon="add" />
4244
<Button icon="remove" />
4345
</ButtonGroup>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
type: feature
2+
feature:
3+
description: Adds a `compact` prop to Divider which removes its margin, making it
4+
flush with adjacent content.
5+
links:
6+
- https://github.com/palantir/blueprint/pull/7501

0 commit comments

Comments
 (0)