// Copyright (c) Tailscale Inc & AUTHORS // SPDX-License-Identifier: BSD-3-Clause import cx from "classnames" import React, { HTMLProps } from "react" import LoadingDots from "src/ui/loading-dots" type Props = { type?: "button" | "submit" | "reset" sizeVariant?: "input" | "small" | "medium" | "large" /** * variant is the visual style of the button. By default, this is a filled * button. For a less prominent button, use minimal. */ variant?: Variant /** * intent describes the semantic meaning of the button's action. For * dangerous or destructive actions, use danger. For actions that should * be the primary focus, use primary. */ intent?: Intent active?: boolean /** * prefixIcon is an icon or piece of content shown at the start of a button. */ prefixIcon?: React.ReactNode /** * suffixIcon is an icon or piece of content shown at the end of a button. */ suffixIcon?: React.ReactNode /** * loading displays a loading indicator inside the button when set to true. * The sizing of the button is not affected by this prop. */ loading?: boolean /** * iconOnly indicates that the button contains only an icon. This is used to * adjust styles to be appropriate for an icon-only button. */ iconOnly?: boolean /** * textAlign align the text center or left. If left aligned, any icons will * move to the sides of the button. */ textAlign?: "center" | "left" } & HTMLProps export type Variant = "filled" | "minimal" export type Intent = "base" | "primary" | "warning" | "danger" | "black" const Button = React.forwardRef((props, ref) => { const { className, variant = "filled", intent = "base", sizeVariant = "large", disabled, children, loading, active, iconOnly, prefixIcon, suffixIcon, textAlign, ...rest } = props const hasIcon = Boolean(prefixIcon || suffixIcon) return ( ) }) export default Button