admin管理员组文章数量:1315296
I want to have a custom icon (not just the suffix icon - to replace the whole UI of the DatePicker), and when I click that icon, I want the DatePicker to open for me to select the date.
const [open, setOpen] = useState(false)
const handleIconClick = () => {
setOpen(true)
};
return(
<CalendarOutlined className="calendar-icon" onClick={handleIconClick} />
<DatePicker style={{display:'none'}}open={open} onOpenChange={setOpen} />
)
This is what I have tried. The DatePicker component is not displayed as display is set to none and when I click on the icon, the DatePicker open UI will render for quick second and disappear. I suspect this is also because the display is set to none.
Is there anyway I can achieve what I want while using the antd DatePicker or will I have to use the date input html element for this purpose?
I want to have a custom icon (not just the suffix icon - to replace the whole UI of the DatePicker), and when I click that icon, I want the DatePicker to open for me to select the date.
const [open, setOpen] = useState(false)
const handleIconClick = () => {
setOpen(true)
};
return(
<CalendarOutlined className="calendar-icon" onClick={handleIconClick} />
<DatePicker style={{display:'none'}}open={open} onOpenChange={setOpen} />
)
This is what I have tried. The DatePicker component is not displayed as display is set to none and when I click on the icon, the DatePicker open UI will render for quick second and disappear. I suspect this is also because the display is set to none.
Is there anyway I can achieve what I want while using the antd DatePicker or will I have to use the date input html element for this purpose?
Share Improve this question asked Jan 30 at 9:50 Upeka FernandoUpeka Fernando 1051 gold badge1 silver badge7 bronze badges1 Answer
Reset to default 1You can set its visibility
to hidden
from the style
prop or through a className
.
<DatePicker
// className="some-classname-which-sets-visibility-to-hidden" or
style={{visibility:'hidden'}}
open={open}
onOpenChange={setOpen}
/>
Example: https://codepen.io/Gabriele-Petrioli/pen/myboyyX?editors=0010
Also found a discussion with an example in github: allow opening DatePicker without need for input box
本文标签: htmlChanging the default UI of Antd DatePicker componentStack Overflow
版权声明:本文标题:html - Changing the default UI of Antd DatePicker component - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741974806a2408055.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论