Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
How to extend button type for antd

I am developing an UI framework based on antd (I call it Yooooo UI)

The design is a little different with the default style of antd and I did something to set the different color, size, margin and blablabla with setting less variables - follow the official solution.

Also, there is something new, such as I extend the type of Buttons - add 'atype', 'btype', 'ctype' to Button Component. That means I can use it like

import { Button } from 'yooooo-ui';

<Button type="atype" />

The solution for supporting this is here below

import { ButtonType } from 'antd/lib/button';
import { BaseButtonProps } from 'antd/lib/button/button';

const ExtendedButtonTypes = tuple(
  'atype',
  'btype',
  'ctype'
);

type ExtendButtonType = typeof ExtendedButtonTypes[number];
type MyButtonType = ButtonType | ExtendButtonType;

interface MyBaseButtonProps extends Omit<BaseButtonProps, 'type'> {
  type?: MyButtonType;
}

// ...something else codes

But there is a condition that Modal component used the Button component with a relative path in antd.

// codes in antd
import { ButtonProps } from './button'
// ...something else

that means, if I do nothing in Yoooo UI and use the Modal component, the button type 'atype' is invalid since Modal component doesn't use my customized Button component

import { Modal } from 'yoooo-ui';

const buttonProps = {
  type: 'atype' // <-- error happened
}

<Modal
  okButtonProps={buttonProps}
/>

I wanna figure out a way to handle this condition with a commonly way.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda