ctify

Button

Buttons have label text that describes the action that will occur if a user taps a button.

Usage

Notice! Button component under react-router Link component will cause refresh page.
  • Solution 1: add onPress(e=>e.preventDefault()) to Button component
  • Solution 2: put Link component under Button component

Props

NameTypeDefaultDescription
formstring—The
element to associate the button with. The value of this attribute must be the id of a in the same document.
formActionstring—The URL that processes the information submitted by the button. Overrides the action attribute of the button's form owner.
formEncTypestring—Indicates how to encode the form data that is submitted.
formMethodstring—Indicates the HTTP method used to submit the form.
formNoValidateboolean—Indicates that the form is not to be validated when it is submitted.
formTargetstring—Overrides the target attribute of the button's form owner.
namestring—Submitted as a pair with the button's value as part of the form data.
valuestring—The value associated with the button's name when it's submitted with the form data.
isPendingboolean—Whether the button is in a pending state. This disables press and hover events while retaining focusability, and announces the pending state to screen readers.
isDisabledboolean—Whether the button is disabled.
autoFocusboolean—Whether the element should receive focus on render.
typebutton submit reset'button'The behavior of the button when used in an HTML form.
preventFocusOnPressboolean—Whether to prevent focus from moving to the button when pressing it.
childrenReact.ReactNode—The children of the component. A function may be provided to alter the children based on component state.
classNamestring—The CSS className for the element. A function may be provided to compute the class based on component state.
styleReact.CSSProperties—The inline style for the element. A function may be provided to compute the style based on component state.
colorprimary secondary tertiary error'primary'
variantelevated filled tonal outlined text'filled'

Events

NameTypeDescription
onPress(e: PressEvent) => voidHandler that is called when the press is released over the target.
onPressStart(e: PressEvent) => voidHandler that is called when a press interaction starts.
onPressEnd(e: PressEvent) => voidHandler that is called when a press interaction ends, either over the target or when the pointer leaves the target.
onPressChange(e: PressEvent) => voidHandler that is called when the press state changes.
onPressUp(e: PressEvent) => voidHandler that is called when a press is released over the target, regardless of whether it started on the target or not.
onFocus(e: FocusEvent<Target>) => voidHandler that is called when the element receives focus.
onBlur(e: FocusEvent<Target>) => voidHandler that is called when the element loses focus.
onFocusChange(isFocused: boolean) => voidHandler that is called when the element's focus status changes.
onKeyDown(e: KeyboardEvent) => voidHandler that is called when a key is pressed.
onKeyUp(e: KeyboardEvent) => voidHandler that is called when a key is released.
onHoverStart(e: HoverEvent) => voidHandler that is called when a hover interaction starts.
onHoverEnd(e: HoverEvent) => voidHandler that is called when a hover interaction ends.
onHoverChange(isHovering: boolean) => voidHandler that is called when the hover state changes.

Layout

NameTypeDescription
slotstring nullA slot name for the component. Slots allow the component to receive props from a parent component. An explicit null value indicates that the local props completely override all props received from a parent.