@chakra-ui/react#ButtonProps TypeScript Examples

The following examples show how to use @chakra-ui/react#ButtonProps. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ToggleColorModeButton.tsx    From coindrop with GNU General Public License v3.0 6 votes vote down vote up
ToggleColorModeButton: FC<ButtonProps> = (buttonProps) => {
    const { colorMode, toggleColorMode } = useColorMode();
    return (
        <Button
            aria-label="Toggle dark mode"
            onClick={toggleColorMode}
            // eslint-disable-next-line react/jsx-props-no-spreading
            {...buttonProps}
        >
            {colorMode === 'light' ? <SunIcon /> : <MoonIcon />}
        </Button>
    );
}
Example #2
Source File: ExportButton.tsx    From calories-in with MIT License 6 votes vote down vote up
function ExportButton({ ...rest }: Props) {
  const screenSize = useScreenSize()
  const dietForm = useDietForm()
  const canExport = canExportDietForm(dietForm)

  const commonProps: ButtonProps = {
    isDisabled: !canExport,
    ...rest,
  }

  if (screenSize >= ScreenSize.Medium) {
    return (
      <Button
        leftIcon={<Share size={16} pointerEvents="none" />}
        variant="solid"
        colorScheme="teal"
        size="md"
        {...commonProps}
      >
        Export
      </Button>
    )
  }

  return (
    <IconButton
      isDisabled={!canExport}
      aria-label="Export"
      colorScheme="teal"
      size="md"
      icon={<Share size={20} pointerEvents="none" />}
      {...commonProps}
    />
  )
}
Example #3
Source File: HeaderMenu.tsx    From openchakra with MIT License 5 votes vote down vote up
CustomMenuButton: React.FC<
  MenuButtonProps | ButtonProps
> = React.forwardRef((props, ref: React.Ref<HTMLLinkElement>) => {
  // @ts-ignore
  return <MenuButton as={Button} {...props} />
})