ant-design/components/space/demo/size.tsx
二货爱吃白萝卜 e7aa014c31
chore: Add type util (#46923)
* docs: init

* chore: all types

* docs: faq

* chore: fix lint
2024-01-11 15:55:58 +08:00

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;