React ANT 设计按钮操作不适用于 Tailwind UI 按钮

发布于 2025-01-10 16:30:41 字数 2571 浏览 0 评论 0原文

//更改名称

const [editNameState, setEditNameState] = useState(false);
const [name, setName] = useState({
    firstName: '',
    lastName: ''
});

//当前功能

<div className="border-2 border-gray-300  py-3 text-sm px-4 mb-6">
     <div className="flex flex-row justify-between mb-2">
          <p>Full Name</p>
          <Buttons 
             title={!editNameState ? 'Edit Full Name' : 'Cancel'} outline onClick={() => {
                    setEditNameState(!editNameState)
                    }}/>
      </div>
      <div className="flex flex-row justify-between my-6">
            <div>
               {editNameState ?
                    <div>
                        <label>First Name</label>
                          <Input value={name.firstName || user.firstName} onChange={(event) => {
                                            setName({...name, firstName: event.target.value})
                                        }}/><br/>
                         <label>Last Name</label>
                           <Input value={name.lastName || user.lastName} onChange={(event) => {
                                            setName({...name, lastName: event.target.value})
                                        }}/>
                                    </div>
                                    :
                                <p>{user.firstName + ' ' + user.lastName}</p>
                }
                </div>
                   {editNameState && <Buttons title="Save" onClick={async () => {
                      setEditNameState(false)
                    await handleNameChange()
                   }}/>}
             </div>
       </div>

//我需要tailwind UI中的新按钮格式

    <button  
        title={!editNameState ? 'Edit Full Name' : 'Cancel'} 
        outline onClick={() => {
                            setEditNameState(!editNameState)
                        }} 
        class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-red-400 hover:bg-red-400 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500">
        Edit Full Name
    </button>

//Ant设计按钮是但在 Tailwind UI 按钮中是按钮文本,在这种情况下 editNameState 不适用于 tailwind 请帮助我像 ant design 一样工作

//changing name

const [editNameState, setEditNameState] = useState(false);
const [name, setName] = useState({
    firstName: '',
    lastName: ''
});

//current function

<div className="border-2 border-gray-300  py-3 text-sm px-4 mb-6">
     <div className="flex flex-row justify-between mb-2">
          <p>Full Name</p>
          <Buttons 
             title={!editNameState ? 'Edit Full Name' : 'Cancel'} outline onClick={() => {
                    setEditNameState(!editNameState)
                    }}/>
      </div>
      <div className="flex flex-row justify-between my-6">
            <div>
               {editNameState ?
                    <div>
                        <label>First Name</label>
                          <Input value={name.firstName || user.firstName} onChange={(event) => {
                                            setName({...name, firstName: event.target.value})
                                        }}/><br/>
                         <label>Last Name</label>
                           <Input value={name.lastName || user.lastName} onChange={(event) => {
                                            setName({...name, lastName: event.target.value})
                                        }}/>
                                    </div>
                                    :
                                <p>{user.firstName + ' ' + user.lastName}</p>
                }
                </div>
                   {editNameState && <Buttons title="Save" onClick={async () => {
                      setEditNameState(false)
                    await handleNameChange()
                   }}/>}
             </div>
       </div>

//What I Need new button format in tailwind UI

    <button  
        title={!editNameState ? 'Edit Full Name' : 'Cancel'} 
        outline onClick={() => {
                            setEditNameState(!editNameState)
                        }} 
        class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-red-400 hover:bg-red-400 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500">
        Edit Full Name
    </button>

//In Ant design button is but in Tailwind UI button is button text in this case editNameState is not working for tailwind please help me to work it same as ant design

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文