mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-22 22:48:29 +08:00
e7aa014c31
* docs: init * chore: all types * docs: faq * chore: fix lint
38 lines
1.1 KiB
TypeScript
38 lines
1.1 KiB
TypeScript
import React, { useState } from 'react';
|
|
import { Button, Radio, Slider, Space } from 'antd';
|
|
import type { ConfigProviderProps } from 'antd';
|
|
|
|
type SizeType = ConfigProviderProps['componentSize'];
|
|
|
|
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;
|