DouyinFE / semi-design

🚀A modern, comprehensive, flexible design system and React UI library. 🎨 Provide more than 3000+ Design Tokens, easy to build your design system. Make Semi Design to Any Design. 🧑🏻‍💻 Design to Code in one click
https://semi.design
Other
8.3k stars 700 forks source link

[TagInput] renderTagItem API with remove function #1219

Closed Saul-BT closed 1 year ago

Saul-BT commented 1 year ago

Which Component Need Enhancement 期望新增功能的组件

What does the proposed API look like 期望支持的API

(value: string, index: number, onRemove: () => void) => React.ReactNode

Where:

Feature Description 功能描述

I know that this component can be controlled, but I think this feature can be interesting to add the functionality to remove tags in a simpler and compact way.

Usage example:

import React from 'react';
import { Button, TagInput } from '@douyinfe/semi-ui';

() => (
    <TagInput 
        defaultValue={['Semi', 'Hotsoon', 'Pipixia']} 
        renderTagItem={(value, _index, onRemove) => (
            <div style={{ margin: 5, backgroundColor: '#AEF' }}>
                <span>{value}</span>
                <Button onClick={onRemove} size='small' icon={<IconClose />} />
            </div>
        )}
    />
);

PROS:

CONS:

Additional information 补充说明

I have not spent much time thinking about the naming of the onRemove function, obviously it can be changed to a more convenient one.

M

YyumeiZhang commented 1 year ago

We will add support for this parameter in next beta version(2.23.0-beta.0)

pointhalo commented 1 year ago

image

2.23.0-beta.0 support

Saul-BT commented 1 year ago

Thank you all for your awesome work and support ❤️