ant-design/components/space/demo/size.tsx
2023-09-11 11:33:45 +08:00

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;