Skip to content

Commit 095da1e

Browse files
committed
fix(back-top): reset native button styles and support custom children
Add border/padding reset for the button element. Add _custom modifier to strip default styling when children are provided. Offset custom trigger demo to prevent overlap with the basic example.
1 parent 6e97d36 commit 095da1e

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

components/back-top/demo/custom.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Use custom children to replace the default button.
77
```jsx live
88
() => {
99
return (
10-
<BackTop visibilityHeight={100}>
10+
<BackTop visibilityHeight={100} style={{ bottom: 100 }}>
1111
<div style={{
1212
width: 40,
1313
height: 40,

components/back-top/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ const BackTop = (props: BackTopProps): JSX.Element | null => {
2727
} = props;
2828
const configContext = useContext(ConfigContext);
2929
const prefixCls = getPrefixCls('back-top', configContext.prefixCls, customisedCls);
30-
const cls = classNames(prefixCls, className);
30+
const cls = classNames(prefixCls, className, {
31+
[`${prefixCls}_custom`]: !!children,
32+
});
3133
const [visible, setVisible] = useState(true);
3234

3335
const getDistanceFromTop = useCallback((): number => {

components/back-top/style/_index.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@
1212
justify-content: center;
1313
align-items: center;
1414
cursor: pointer;
15+
border: none;
16+
padding: 0;
1517
transition: opacity 200ms linear 0s, visibility;
18+
19+
&_custom {
20+
background: none;
21+
width: auto;
22+
height: auto;
23+
border-radius: 0;
24+
}
1625
}

0 commit comments

Comments
 (0)