mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-24 07:28:28 +08:00
ce1721b169
* demo: improve button gradient demo * demo: improve button gradient demo
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import React, { useContext } from 'react';
|
|
import { Button, ConfigProvider, Space } from 'antd';
|
|
import { AntDesignOutlined } from '@ant-design/icons';
|
|
import { css } from '@emotion/css';
|
|
|
|
const App: React.FC = () => {
|
|
const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
|
|
const rootPrefixCls = getPrefixCls();
|
|
const linearGradientButton = css`
|
|
&.${rootPrefixCls}-btn-primary:not([disabled]):not(.${rootPrefixCls}-btn-dangerous) {
|
|
border-width: 0;
|
|
|
|
> span {
|
|
position: relative;
|
|
}
|
|
|
|
&::before {
|
|
content: '';
|
|
background: linear-gradient(135deg, #6253E1, #04BEFE);
|
|
position: absolute;
|
|
inset: 0;
|
|
opacity: 1;
|
|
transition: all 0.3s;
|
|
border-radius: inherit;
|
|
}
|
|
|
|
&:hover::before {
|
|
opacity: 0;
|
|
}
|
|
}
|
|
`;
|
|
return (
|
|
<ConfigProvider
|
|
button={{
|
|
className: linearGradientButton,
|
|
}}
|
|
>
|
|
<Space>
|
|
<Button type="primary" size="large" icon={<AntDesignOutlined />}>
|
|
Gradient Button
|
|
</Button>
|
|
<Button size="large">Button</Button>
|
|
</Space>
|
|
</ConfigProvider>
|
|
);
|
|
};
|
|
|
|
export default App;
|