Actions

Button

Buttons for actions and links.

Class nameTypeDescription
btnplf:btnComponentButton; neutral on its own
btn-iconplf:btn-iconPartAn SVG icon in the button; an icon class there doesn't need it
btn-icon-loadingplf:btn-icon-loadingPartDraws and spins the loader
btn-labelplf:btn-labelPartThe label, which the loading part replaces while loading
btn-loadingplf:btn-loadingPartShown in the label's place while loading
btn-outlineplf:btn-outlineStyleOutline on the surface
btn-ghostplf:btn-ghostStyleNo background or border until hover
btn-linkplf:btn-linkStyleLooks like a link
btn-softplf:btn-softStyleA light fill in the color
btn-neutralplf:btn-neutralColorNeutral (dark) color
btn-primaryplf:btn-primaryColorPrimary color
btn-errorplf:btn-errorColorError color, for destructive actions
btn-successplf:btn-successColorSuccess color
btn-warningplf:btn-warningColorWarning color
btn-infoplf:btn-infoColorInfo color
btn-smplf:btn-smSizeSmall
btn-lgplf:btn-lgSizeLarge
btn-squareplf:btn-squareModifierSquare, for an icon-only button
btn-circleplf:btn-circleModifierRound, for an icon-only button

Button tags

<button> for actions, <a> for navigation. Inside a form a button submits it, so add type="button" to one that should not.

Link

Disabled

A link cannot be disabled: give it aria-disabled="true" and leave out href.

Link

Loading

Put the label in btn-label and the loading text in btn-loading. PLF.Button.loading(button, true) shows the loading part and false brings the label back; the button keeps its width.

Loading on submit

On a form that loads a new page, such as a WordPress settings page, data-plf-loading-on-submit shows the loading part once the form submits and blocks a second submission, with no script of your own. A form that only downloads a file keeps its page, so leave the attribute off there.

With icons

An icon-only button needs an aria-label.

Login buttons

Each brand’s colors go through Button’s variables, and each logo is its owner’s trademark, used as its sign-in guidelines say; Google’s 2025 guidelines ask for its newer gradient “G”, from Google’s branding page.

JavaScript

Only loading needs JavaScript, and its helper needs no init(). The Full script (pelatform-ui.min.js) starts every component on page load, with no code of your own; with ESM imports, call init() yourself, as in Installation. For markup you add later, see Dynamic content.

<link rel="stylesheet" href="pelatform-ui.min.css">
<link rel="stylesheet" href="icons/icons.min.css">
<script src="pelatform-ui.min.js" defer></script>
<link rel="stylesheet" href="pelatform-ui.prefixed.min.css">
<link rel="stylesheet" href="icons/icons.prefixed.min.css">
<script src="pelatform-ui.min.js" defer></script>
Attribute Purpose
data-plf-loading-on-submit On a submit button: once its form submits and the browser loads the next page, shows the loading part and disables the button. A submission your script cancels, to send it with fetch, is left to PLF.Button.loading(); a page restored with Back shows the button ready again
Method Behavior
PLF.Button.loading(button, true) Disables the button and shows btn-loading in the label’s place
PLF.Button.loading(button, false) Gives the button, its label and its focus back
PLF.Button.loading(button, promise) Loading until the promise, such as fetch(…), settles, even when it fails; resolves to its result. A function that returns a promise works too
PLF.Button.getOrCreateInstance(button), getInstance(button) The instance of a data-plf-loading-on-submit button, or null; instance.destroy() removes its listeners and ends a loading state it started

Without the script, set aria-busy="true" and disabled on the button while your action runs.

React

Button from @pelatform/react renders this markup from its props, and buttonClass() gives a link or a router’s Link the same classes.

Prop Values Default
color neutral, primary, error, success, warning, info; a soft button takes all but neutral, and outline, ghost and link take none Neutral
variant outline, ghost, link, soft Filled
size sm, lg The default size
shape square, circle, for an icon-only button with an aria-label None
loading true while your action runs: the button is busy and disabled, and gets its focus back afterwards false
loadingText Text or elements shown with a spinner in the label’s place while loading; the children become the label None

The other props are a native button’s, className and ref included; buttonClass() takes color, variant, size and shape.

CSS variables

Override on a root or on a single button. On a root, the four color variables reach every variant, ghost and link included: scope them to a variant class such as .btn-primary (.plf\:btn-primary with Prefixed CSS), or set --plf-color-primary to recolor every primary use, hover included.

Variable Default
--plf-button-bg, --plf-button-color, --plf-button-border, --plf-button-hover-bg The variant’s colors
--plf-button-shadow --plf-shadow-xs; none on ghost, link and disabled
--plf-button-height 32px small, 36px default, 40px large
--plf-button-padding-inline 12px, 16px, 24px (8px, 12px, 16px with an icon)
--plf-button-radius Large radius (8px)
--plf-button-icon-size 14px, 16px, 18px

Built with Pelatform UIv0.1.0

Components

Getting started

Foundations

Components

Actions

Data display

Navigation

Feedback

Data input

Layout

Advanced

Integrations

Blocks

Application

Authentication

Icons