mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-14 08:09:13 +08:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { Button, Radio, Slider, Space } from 'antd';
|
|
import type { SizeType } from 'antd/es/config-provider/SizeContext';
|
|
|
|
const App: React.FC = () => {
|
|
const [size, setSize] = useState<SizeType | [SizeType, SizeType] | 'customize'>('small');
|
|
const [customSize, setCustomSize] = React.useState<number>(0);
|
|
return (
|
|
<>
|
|
<Radio.Group value={size} onChange={(e) => setSize(e.target.value)}>
|
|
{['small', 'middle', 'large', 'customize'].map((item) => (
|
|
<Radio key={item} value={item}>
|
|
{item}
|
|
</Radio>
|
|
))}
|
|
</Radio.Group>
|
|
<br />
|
|
<br />
|
|
{size === 'customize' && (
|
|
<>
|
|
<Slider value={customSize} onChange={setCustomSize} />
|
|
<br />
|
|
</>
|
|
)}
|
|
<Space size={size !== 'customize' ? size : customSize}>
|
|
<Button type="primary">Primary</Button>
|
|
<Button>Default</Button>
|
|
<Button type="dashed">Dashed</Button>
|
|
<Button type="link">Link</Button>
|
|
</Space>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|