Buttons communicate an action to happen on user interaction.

installyarn add @clayui/button
versionNPM Version
useimport Button from '@clayui/button';

Display Types

You can determine how your button can be displayed using the displayType property:

If you want use the button as a link set displayType to link.

import {Provider} from '@clayui/core';
import Button from '@clayui/button';
import React from 'react';

import '@clayui/css/lib/css/atlas.css';

export default function App() {
	return (
		<Provider spritemap="/public/icons.svg">
			<div className="p-4">
				<Button.Group spaced>
					<Button displayType="primary">Button Primary</Button>
					<Button displayType="secondary">Button Secondary</Button>
					<Button displayType="link">Button Link</Button>
					<Button borderless>Button Borderless</Button>
				</Button.Group>
			</div>
		</Provider>
	);
}

Group

You can use the variant Button.Group for creating button groups:

Use the spaced property to create spacing between buttons.

import {Provider} from '@clayui/core';
import Button from '@clayui/button';
import React from 'react';

import '@clayui/css/lib/css/atlas.css';

export default function App() {
	return (
		<Provider spritemap="/public/icons.svg">
			<div className="p-4">
				<Button.Group>
					<Button>This</Button>
					<Button displayType="secondary">is</Button>
					<Button>a</Button>
					<Button displayType="secondary">button</Button>
					<Button>group.</Button>
				</Button.Group>
			</div>
		</Provider>
	);
}

Icon

You can use the high-level component ClayButtonWithIcon to create a button with only an icon. If you need an icon and text, you need to compose with ClayIcon

import {Provider} from '@clayui/core';
import Button, {ClayButtonWithIcon} from '@clayui/button';
import Icon from '@clayui/icon';
import React from 'react';

import '@clayui/css/lib/css/atlas.css';

export default function App() {
	return (
		<Provider spritemap="/public/icons.svg">
			<div className="p-4">
				<ClayButtonWithIcon
					aria-label="Close"
					symbol="times"
					title="Close"
				/>
				<Button>
					<span className="inline-item inline-item-before">
						<Icon symbol="times" />
					</span>
					Close w/ text
				</Button>
			</div>
		</Provider>
	);
}

API Reference

Button

IForwardRef<HTMLButtonElement, IProps>
Parameters

alert

boolean | undefined

Flag to indicate if button is used within an alert component.

borderless

boolean | undefined

Flag to indicate if the button should be borderless.

block

boolean | undefined

Renders the button as a block element.

dark

boolean | undefined

Flag to indicate if the button should use the clay-dark variant.

displayType

DisplayType | undefined

Determines the button variant to use. The values beta and beta-dark are deprecated since v3.100.0 - use translucent and dark instead. The values null and unstyled are for internal use only.

monospaced

boolean | undefined

Flag to indicate if button should be monospaced.

outline

boolean | undefined

Flag to indicate if the button should use the outline variant.

rounded

boolean | undefined

Flag to indicate if the button should be shaped like a pill.

size

"xs" | "sm" | "regular" | undefined

Determines the size of a button.

small

boolean | undefined

Indicates button should be a small variant.

translucent

boolean | undefined

Flag to indicate if the button should use the translucent variant.

Returns
ReactElement<any, string | JSXElementConstructor<any>> | null

ClayButtonWithIcon

React.ForwardRefExoticComponent<Pick<Props, "symbol" | "block" | "borderless" | "children" | "className" | "displayType" | "monospaced" | "outline" | "small" | "type" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "slot" | "spellCheck" | "style" | "tabIndex" | "title" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "disabled" | "spritemap" | "size" | "key" | "alert" | "dark" | "rounded" | "translucent" | "autoFocus" | "form" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "name" | "value"> & React.RefAttributes<HTMLButtonElement>>
Parameters
Properties

symbol *

string

The id of the icon in the spritemap.

block

boolean | undefined

Renders the button as a block element.

borderless

boolean | undefined

Flag to indicate if the button should be borderless.

displayType

DisplayType | undefined

Determines the button variant to use. The values beta and beta-dark are deprecated since v3.100.0 - use translucent and dark instead. The values null and unstyled are for internal use only.

monospaced

boolean | undefined

Flag to indicate if button should be monospaced.

outline

boolean | undefined

Flag to indicate if the button should use the outline variant.

small

boolean | undefined

Indicates button should be a small variant.

aria-label *

string | undefined

Define a value that labels the button.

aria-labelledby

string | undefined

spritemap

string | undefined

Path to the location of the spritemap resource.

size

"xs" | "sm" | "regular" | undefined

Determines the size of a button.

alert

boolean | undefined

Flag to indicate if button is used within an alert component.

dark

boolean | undefined

Flag to indicate if the button should use the clay-dark variant.

rounded

boolean | undefined

Flag to indicate if the button should be shaped like a pill.

translucent

boolean | undefined

Flag to indicate if the button should use the translucent variant.

Returns
ReactElement<any, string | JSXElementConstructor<any>> | null

Group

{ ({ children, className, role, spaced, vertical, ...otherProps }: Props): JSX.Element; displayName: string; }
Parameters
Properties

spaced

boolean | undefined

Flag to indicate the spacing between the buttons.

vertical

boolean | undefined

Flag to indicate if buttons are stacked vertically.

Returns
Element
Edit this page on GitHub

Contributors

Matuzalém Teles, Diego Nascimento, Bryce Osterhaus, Patrick Yeo, Krešimir Čoko, Ilza Medeiros

Last edited January 29, 2025 at 1:35:02 AM