简体   繁体   中英

Modify Ant Design (antd) time picker footer text

Is there any way to modify the text from the "Now" and "Ok" button in Ant Design Time Picker? Either using react or antd.

在此处输入图像描述

Thanks in advance.

I was looking at props if something is available to modify the footer, the only prop I found relevant to footer was 'renderExtraFooter', seems like there is nothing from ant that we can use to replace the text of these buttons.

However, there is a CSS way to replace the text using ::after selector like below.

a.ant-picker-now-btn {
  font-size: 0;
}

a.ant-picker-now-btn:after {
  content: "ABC";
  font-size: 16px; /* original font size */
}

Sharing the codesandbox below - https://codesandbox.io/s/basic-antd4150-forked-pyd95?file=/index.css

You can control the text of the "Now" and "Ok" buttons by using the locale prop. You must provide a complete locale configuration, not just the lang.now and lang.ok properties. So you can import one of the standard language configs and merge them.

import { TimePicker } from "antd";
import "antd/dist/antd.css";
import locale from "antd/es/date-picker/locale/de_DE";

console.log(locale);

export default () => (
  <TimePicker
    locale={{
      ...locale,
      lang: {
        ...locale.lang,
        now: "Current Time",
        ok: "Submit",
      }
    }}
  />
);

You can also set sitewide labels using a ConfigProvider .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM