Files
ant-design/components/mentions/demo/style-class.tsx
二货爱吃白萝卜 b9f1d1239c feat: Mentions reduce dom strcuture and support size (#55638)
* chore: init mentions

* feat: Mentions support size

* chore: update demo

* chore: adjust style

* test: update snapshot

---------

Co-authored-by: thinkasany <480968828@qq.com>
Co-authored-by: 遇见同学 <1875694521@qq.com>
2025-11-08 14:42:59 +08:00

59 lines
1.3 KiB
TypeScript

import React from 'react';
import { Flex, Mentions } from 'antd';
import type { MentionsProps } from 'antd';
import { createStyles } from 'antd-style';
const useStyles = createStyles(({ token }) => ({
root: {
border: `1px solid ${token.colorPrimary}`,
borderRadius: 8,
width: 300,
},
}));
const options: MentionsProps['options'] = [
{ value: 'afc163', label: 'afc163' },
{ value: 'zombieJ', label: 'zombieJ' },
{ value: 'meet-student', label: 'meet-student' },
{ value: 'thinkasany', label: 'thinkasany' },
];
const stylesObject: MentionsProps['styles'] = {
textarea: {
fontSize: 14,
resize: 'vertical',
fontWeight: 200,
},
};
const stylesFunction: MentionsProps['styles'] = (info) => {
if (info.props.variant === 'filled') {
return {
root: {
border: '1px solid #722ed1',
},
popup: {
border: '1px solid #722ed1',
},
} satisfies MentionsProps['styles'];
}
};
const App: React.FC = () => {
const { styles: classNames } = useStyles();
const sharedProps: MentionsProps = {
options,
classNames,
};
return (
<Flex vertical gap="middle">
<Mentions {...sharedProps} styles={stylesObject} placeholder="Object" rows={2} />
<Mentions {...sharedProps} styles={stylesFunction} variant="filled" placeholder="Function" />
</Flex>
);
};
export default App;