Button
Overview
The Button component provides a flexible and highly customizable button for your Bulma React UI.
It supports all Bulma color, size, and state modifiers, as well as additional helper classes for text, spacing, and more.
Use Button for real button actions (submit, toggle, open a dialog). For a link-styled click target or client-side navigation, prefer LinkButton — using Button as a fake link/<div onClick> loses proper anchor and a11y semantics.
Make sure to provide meaningful text or accessible content for screen readers.
Import
import { Button } from '@allxsmith/bestax-bulma';
Usage
Default Button
This is the most fundamental use of the Button component, providing a simple yet stylish Bulma button for general actions. Use the default configuration (no extra props required) for forms, dialogs, toolbars, or anywhere you need a straightforward clickable action with Bulma’s default styling.
<Button>Default Button</Button>
All Colors
By setting the color prop, you can style your button with any of Bulma's button colors. The semantic colors are primary, link, info, success, warning, and danger. Neutral colors are white, light, dark, and black. Special colors are text (minimal text-only button) and ghost (link-like button). This allows you to visually communicate the purpose of different actions—for example, use success for confirming, danger for destructive actions, or ghost for a button that looks like a link.
<Buttons> {(['primary', 'link', 'info', 'success', 'warning', 'danger'] as const).map( color => ( <Button key={color} color={color}> {color.charAt(0).toUpperCase() + color.slice(1)} </Button> ) )} </Buttons>
All Sizes
The size prop lets you adjust the button’s scale for various contexts. Supported values for size are small, normal, medium, and large. Use small for compact UIs, large for important calls to action, and normal or medium for general use.
<Buttons> {(['small', 'normal', 'medium', 'large'] as const).map(size => ( <Button key={size} size={size}> {size.charAt(0).toUpperCase() + size.slice(1)} </Button> ))} </Buttons>
With an Icon
Put an Icon and the text side by side inside the Button, with the text in a <span> of its own. Bulma spaces an icon by where it sits among the button's elements, and a bare text node isn't an element, so without the <span> the icon gets the margins of an icon-only button and the text sits flush against it. Put the Icon first for a leading icon, or last for a trailing one, such as the arrow on a call to action. Leave the Icon unnamed, since the text already names the button.
<Buttons> <Button color="primary"> <Icon name="download" aria-hidden="true" /> <span>Download</span> </Button> <Button color="link" isOutlined> <span>Get started</span> <Icon name="arrow-right" aria-hidden="true" /> </Button> </Buttons>
Light Variant
Create a softer, pastel version of a colored button by adding the isLight prop. Combined with a color such as primary, it produces a much lighter shade. This is useful for secondary actions or when you want your button to coordinate with your theme color without drawing too much attention. Bulma's grayscale colors, white, black, light and dark, have no light variant, and the isLight row under Props says what each of them looks like with it.
<Button color="primary" isLight> Light Primary Button </Button>
Rounded
Enable the isRounded prop to give your button fully rounded edges. This style can help actions look friendlier and more approachable, and is often used in toolbars, cards, or to make special actions stand out visually.
<Button color="info" isRounded> Rounded Button </Button>
Loading
Set the isLoading prop to display a loading spinner inside the button. This is commonly used while waiting for an asynchronous operation, such as form submission or data fetching, providing user feedback and preventing multiple submissions: a click, Enter or Space does nothing while it's set, so onClick doesn't run and a submit button doesn't submit its form, and the button tells a screen reader it's busy. Everything inside the button is hidden while isLoading is active, an Icon or a Tag included, and the button keeps its size. A link inside a loading button, in a Button rendered as="div", say, still takes keyboard focus, so it shows while it has it. The button itself keeps focus too, and shows Bulma's focus outline while it has it from the keyboard. Under prefers-reduced-motion: reduce the spinner stops and stays drawn, so the loading state is still visible. In forced colors (Windows' contrast themes), all of it stays hidden too. The button keeps the colors the theme gives it when it's idle: a button's, a link's on an <a> with an href, and the page's on anything else. A selected one, drawn in the system's highlight colors when it's idle, takes those same colors while it loads. A variant with no surface of its own, like ghost or text, stays clear, and since it's the page that shows through, its border and spinner take the page's text color, or a link's on a link. Its focus outline there is drawn in its border color.
<Button color="success" isLoading> Loading Button </Button>
Static
The isStatic prop draws Bulma's static look, a button's shape that doesn't respond to the pointer, for a label such as a domain or a country code beside an input in a Field with addons. It only styles the element, so a <button> is still a tab stop that a screen reader announces as a button. For a label that does nothing, render it as="span", as here, which Tab skips and a screen reader reads as text.
<Button as="span" isStatic> Static Button </Button>
Full Width
With the isFullwidth prop, your button will expand to completely fill the width of its parent container. This is useful for mobile layouts, modal footers, or anywhere you want your call-to-action to be easy to find and tap. (The isFullWidth spelling still works as a deprecated alias.)
<Button color="warning" isFullwidth> Full Width Button </Button>
Outlined
Use the isOutlined prop to give your button a simple outlined style instead of a solid fill. This works in conjunction with the color prop and is ideal for secondary actions. The possible values for color here are the same as above: primary, link, info, success, warning, or danger.
<Button color="danger" isOutlined> Outlined Button </Button>
Inverted
The isInverted prop inverts the button’s color, making it suitable for placement on colored backgrounds. When paired with a color (such as link), it ensures the button maintains contrast and legibility regardless of the surrounding layout.
<Button color="link" isInverted> Inverted Button </Button>
Focused
Show a focused state by enabling the isFocused prop. This can help demonstrate keyboard navigation and accessibility features, as it visually marks which button is currently focused in the UI.
<Button color="primary" isFocused> Focused Button </Button>
Active
The isActive prop draws Bulma's active state, the slightly darker shade every button shows while the mouse is down. It's visual only: it sets no aria-pressed, so a screen reader hears a plain button. For a button that stays on or off, such as Bold or Mute, use ToggleButton, which reports its state and has a pressed look you can see at a glance.
<Button color="info" isActive> Active Button </Button>
Hovered
By setting the isHovered prop, you can force the button to display its hover style. This can be useful for UI previews, tutorials, or custom scenarios where you want to visually indicate what happens on mouseover, without requiring actual pointer interaction.
<Button color="success" isHovered> Hovered Button </Button>
Ghost
Use color="ghost" to render a button that looks like a link but behaves as a <button>. This is useful when you need an action trigger (not navigation) that visually blends with surrounding text, without resorting to a <div onClick> pattern.
<Button color="ghost">Ghost Button</Button>
Text
Use color="text" to render a minimal text-only button with no background or border. This is ideal for subtle actions in toolbars or inline contexts where a standard button would be too prominent.
<Button color="text">Text Button</Button>
Disabled
To make a button inactive, use the isDisabled prop. A <button> gets the native disabled attribute, and a link, or any other element, gets aria-disabled, with the same disabled look.
<Buttons> <Button color="warning" isDisabled> Disabled Button </Button> <Button color="warning" as="a" href="#next" isDisabled> Disabled Link </Button> </Buttons>
Custom Text and Background Color
With the textColor and bgColor props, you can independently set the button’s foreground and background colors. Accepted values for both are any Bulma color, such as primary, info, danger, etc. This approach lets you create unique, branded, or visually striking button styles beyond the defaults.
<Button textColor="danger" bgColor="info"> Custom Text & Background </Button>
Spacing Helpers
Add margin and padding to your button using Bulma’s spacing helper props: m, p, mx, my, mt, mr, mb, and ml. These accept numeric values (e.g., 2, 4), letting you fine-tune the space around your button directly from props, without custom CSS.
<Button m="2" p="3" mx="4" my="5" mt="1" mr="2" mb="3" ml="4"> Button with Spacing </Button>
Text Alignment
Control the horizontal alignment of the button’s text using the textAlign prop. Possible values are centered, justified, left, and right. This is especially useful for full-width or toolbar buttons where text alignment matters for readability and style.
<Button textAlign="centered">Centered Text Button</Button>
Responsive Viewport
The viewport prop allows you to apply responsive styles for specific breakpoints. Accepted values include mobile, tablet, desktop, widescreen, and fullhd. This makes it easy to tailor your button’s appearance for different devices and screen sizes.
<Button viewport="mobile">Mobile Responsive Button</Button>
Flexbox Layout
Bulma’s flexbox helpers, like display="flex", justifyContent, and alignItems, can be applied as props. For justifyContent, use center, start, end, space-between, space-around, or space-evenly; for alignItems, use center, start, end, baseline, or stretch. This lets you precisely control the layout of button content, such as centering icons and text.
<Button display="flex" justifyContent="center" alignItems="center"> Flex Button </Button>
Button Group
Group multiple buttons together using the <Buttons hasAddons> component. The hasAddons prop ensures the buttons are visually connected, making it perfect for toolbars, segmented controls, or navigation layouts where related actions need to be grouped as a unit.
<Buttons hasAddons> <Button color="primary">Left</Button> <Button color="primary">Center</Button> <Button color="primary">Right</Button> </Buttons>
With HTML Attributes
You can pass any standard HTML attributes to the Button component, such as type (possible values: button, submit, or reset) and className. This ensures compatibility with forms, accessibility tooling, and integration with other React libraries.
<Button type="submit" className="custom-class"> Submit Button </Button>
Polymorphic as (Router Links)
The as prop accepts any React.ElementType, not just 'button' or 'a'. This lets Button render as a router's Link component (React Router, Next.js, TanStack Router, etc.) while keeping Bulma's button styling and real anchor semantics — href, middle-click, right-click "copy link", and correct accessibility all keep working, unlike a useNavigate()-in-onClick wrapper.
import { Link as RouterLink } from 'react-router-dom';
import { Button } from '@allxsmith/bestax-bulma';
<Button as={RouterLink} to="/visit" color="primary">
Book a visit
</Button>;
The props follow as, so the type checker already limits what you can pass to what the target accepts. At runtime Button applies two narrow backstops, for JavaScript callers and spread objects that the type checker never sees. The submit-override attributes (formAction, formEncType, formMethod, formNoValidate, formTarget) are withheld from an <a> — they belong to a submit control. And disabled is withheld from any element that does not own it, because Bulma styles .button[disabled] and a stray one would render the element greyed out. Everything else is forwarded, including to an as="input" that legitimately owns name, value and the submit overrides.
Forwarded ref
Button forwards a ref to the element it renders. That element follows as, so the ref points at a <button> by default and at whatever you asked for otherwise — an <a> under as="a".
function example() { const buttonRef = React.useRef<HTMLButtonElement>(null); const [tag, setTag] = React.useState<string>(); return ( <> <Button color="primary" ref={buttonRef}> Target </Button> <Button ml="2" onClick={() => setTag(buttonRef.current?.tagName)}> Read the tag from its ref </Button> <p>Rendered element: {tag ?? '—'}</p> </> ); }
Accessibility
- Labeling: Always provide descriptive content for buttons for screen readers.
- Icons beside text: Leave the
Iconunnamed, so the text alone names the button. The icons in With an Icon write outaria-hidden="true", andIconwould render it for them anyway, since they have noariaLabel,aria-labeloraria-labelledbyto name them and noroleortabIndexof their own. A named icon joins the button's name instead, soariaLabel="Download"on the icon of a Download button makes a screen reader announce "Download Download". - States: The
isDisabledanddisabledprops ensure correctaria-disabledanddisabledattributes. - Disabled look: with any
asbut the default<button>, such as a link,isDisabledwritesaria-disabledand nodisabledattribute, so Bulma doesn't dim it. bestax's styles draw it the way Bulma draws a disabled<button>: at Bulma's disabled opacity, with its disabled fill, edge and shadow, or a colored button's own color, and a not-allowed cursor. So a disabled link looks as unavailable as a screen reader announces it. - Loading: while
isLoadingis set, the button carriesaria-busy="true"andaria-disabled="true", so a screen reader can tell it won't respond, and a click, Enter or Space does nothing:onClickdoesn't run, a submit button doesn't submit its form, and a click on a link doesn't follow itshref. It keeps focus, sincearia-disableddoesn't take it away the waydisabledwould. - Keyboard: When rendered as
<a>, disabled buttons are not focusable. - Focus: Use
isFocusedandisActivefor visual feedback, but rely on browser focus for actual accessibility. - Focus ring: Bulma shows a focused button with its border and a shadow. A ghost button has neither. A loading or static one has no shadow. All a loading one keeps is its border turning the focus color, which on a colored one is drawn on its own fill, and a loading outlined or text one, or a static one, doesn't change at all. Forced colors (Windows' contrast themes) drops the shadow and sets the border's color. A disabled link's disabled look takes the place of its focus border and shadow, as Bulma's does on a disabled
<button>, which can't take focus. So bestax's styles give a focused ghost, loading or static button, a focused disabled link, and every focused button in forced colors, an outline.isFocuseddraws it too. - Forced colors: In Windows' contrast themes a colored button keeps a 1px border, so it still has an edge when the theme replaces its fill, while an outlined button and a
textone are left as they are. Bulma's disabled opacity doesn't apply there, since it would only fade the system's color for a disabled control: a disabled button, one withdisabledor inside a disabled<fieldset>, is drawn in that color at full strength, and so is a link withisDisabled. Bulma also dims a link in a disabled<fieldset>, and a button in its first<legend>, though both still work, so there they're drawn at full strength in their own colors. A button with Bulma'sis-selected, such as a pressedToggleButtonor the selected button of aButtons hasAddonsrow, is drawn in the system's highlight colors there, since the fill that marks it is replaced, and a disabled one in the system's color for a disabled control, filled. - Outlined on the dark scheme: bestax's styles draw an outlined button's label and border at the lightness Bulma picks for its color's text on the page wherever that's lighter than the color's own, so a dark color, such as Bulma's link or bestax's blue primary, reads on the dark page. On a light page an outlined button keeps its color's own lightness. On a surface that stays light on both schemes, such as
bgColor="white", give the surface Bulma'stheme-lightclass (bestax-theme-lightunder thebestax-prefix), which keeps what's inside it on the light scheme's values. - Static labels:
isStaticonly styles the button, so a<button>with it is still a tab stop that a screen reader announces as a button. Render a label that does nothing, such as an addon's "@gmail.com",as="span". - Toggles:
isActivetells a screen reader nothing. A button that turns something on or off is aToggleButton, which setsaria-pressed.
A button that shows only an icon is an IconButton, whose types require an
aria-label or an aria-labelledby, and whose isRounded makes a circle. On a plain Button holding only
an icon, name it with aria-label yourself.
Related Components
Buttons: Group multiple buttons together, including add-ons and alignment.ToggleButton: A button that stays pressed while something is on, and says so througharia-pressed.IconButton: A button that shows only an icon, with the name its types require.CopyButton: A button that copies a piece of text and announces the result.Icon: Inline icons for use inside buttons.- Helper Props: List of all supported Bulma helper props for spacing, colors, etc.
Additional Resources
You can use Bulma helper props with <Button /> for powerful utility-based styling.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
as | React.ElementType | 'button' | Render as a <button>, <a>, or a custom component (e.g. a router Link). Defaults to 'button'; anything else renders through the anchor path, which adds href/target/rel and withholds the submit-override attributes (formAction and friends) from an <a>. |
color | 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger' | 'white' | 'light' | 'dark' | 'black' | 'text' | 'ghost' | — | Bulma color variant for the button. ghost renders a link-like button; text renders a minimal text-only button. |
size | 'small' | 'normal' | 'medium' | 'large' | — | Size of the button. |
isLight | boolean | false | Applies the light variant of a colored button, such as primary's. Bulma gives the grayscale colors none, so with no color, or with white or black, isLight gives the light button, as color="light" does, and light or dark with isLight looks the same as without it. |
isRounded | boolean | false | Makes the button rounded. |
isLoading | boolean | false | Displays a loading spinner, with everything inside the button hidden behind it, in forced colors (Windows' contrast themes) too, and holds the button still: a click, Enter or Space does nothing, so onClick doesn't run, a submit button doesn't submit its form and a click on a link doesn't follow its href, until it's cleared. A custom as component gets that dropped click as its onClick, so it holds still as far as it acts through it. Set it while an action is in progress, so nobody sends it twice. The button carries aria-busy and aria-disabled meanwhile, so a screen reader can tell it won't respond, and stays focusable, so focus isn't lost, with Bulma's focus outline showing it from the keyboard. Under prefers-reduced-motion: reduce the spinner stops and stays drawn. Bulma alone stops only the pointer, hides only the label and takes away the shadow that shows a focused button, so the rest of the look needs bestax's CSS loaded. |
isStatic | boolean | false | Draws Bulma's static look and stops the pointer. It doesn't change the element: a <button> with it is still a tab stop that a screen reader announces as a button and Enter and Space press, and in a form it's a submit button. A label that does nothing, such as "@gmail.com" beside an input in a Field with addons, is a Button rendered as="span", which Tab skips and a screen reader reads as text. |
isFullwidth | boolean | false | Makes the button full-width. |
isFullWidth | boolean | false | Deprecated. Use isFullwidth instead — isFullwidth wins if both are set. Makes the button full-width. |
isOutlined | boolean | false | Applies outlined styling (requires color). On the dark scheme, bestax's stylesheets draw the label and border at the lightness Bulma picks for the color's text on the page wherever that's lighter, so a dark color reads there. On a surface that stays light on both schemes, give the surface Bulma's theme-light class (with the class prefix in a prefixed build), which keeps what's inside it on the light scheme's values. |
isInverted | boolean | false | Applies inverted styling (requires color). |
isFocused | boolean | false | Applies focused styling (visual only). |
isActive | boolean | false | Applies active styling (visual only), with no aria-pressed. For a button that stays pressed, use ToggleButton. |
isHovered | boolean | false | Applies hovered styling (visual only). |
isDisabled | boolean | false | Disables the button. With the default as, the <button> gets the disabled attribute. With any other as, such as a link or a component of your own, it gets aria-disabled and tabIndex={-1} in its place, its onClick doesn't run, and bestax's CSS draws it the way Bulma draws a disabled <button>, which Bulma alone doesn't. |
className | string | — | Custom class name. |
textColor | Bulma color | 'inherit' | 'current' | — | Text color helper. |
bgColor | Bulma color | 'inherit' | 'current' | — | Background color helper. |
children | React.ReactNode | — | Button content. |
ref | PolymorphicRef<React.ElementType> | — | Ref forwarded to the element as renders, typed from as: the DOM node for an intrinsic tag, or whatever handle a custom component exposes. |
... | Remaining props of the element or component selected by as (default <button>) and Bulma helper props | — | See Helper Props |
CSS & Sass Variables
Button registers these variables on its own .button element. Override them there (or via className) — a value set on an ancestor is only inherited, and loses to the component-level declaration. See Theme.
| CSS Variable | Sass Variable | Default |
|---|---|---|
--bulma-button-family | $button-family | false |
--bulma-button-weight | $button-weight | var(--bulma-weight-medium) |
--bulma-button-border-color | $button-border-color | var(--bulma-border) |
--bulma-button-border-style | $button-border-style | solid |
--bulma-button-border-width | $button-border-width | var(--bulma-control-border-width) |
--bulma-button-padding-vertical | $button-padding-vertical | 0.5em |
--bulma-button-padding-horizontal | $button-padding-horizontal | 1em |
--bulma-button-focus-border-color | $button-focus-border-color | var(--bulma-link-focus-border) |
--bulma-button-focus-box-shadow-size | $button-focus-box-shadow-size | 0 0 0 0.125em |
--bulma-button-focus-box-shadow-color | $button-focus-box-shadow-color | hsla(var(--bulma-link-h), var(--bulma-link-s), var(--bulma-link-on-scheme-l), 0.25) |
--bulma-button-active-color | $button-active-color | var(--bulma-link-active) |
--bulma-button-active-border-color | $button-active-border-color | var(--bulma-link-active-border) |
--bulma-button-text-color | $button-text-color | var(--bulma-text) |
--bulma-button-text-decoration | $button-text-decoration | underline |
--bulma-button-text-hover-background-color | $button-text-hover-background-color | var(--bulma-background) |
--bulma-button-text-hover-color | $button-text-hover-color | var(--bulma-text-strong) |
--bulma-button-ghost-background | $button-ghost-background | none |
--bulma-button-ghost-border-color | $button-ghost-border-color | transparent |
--bulma-button-ghost-color | $button-ghost-color | var(--bulma-link-text) |
--bulma-button-ghost-decoration | $button-ghost-decoration | none |
--bulma-button-ghost-hover-color | $button-ghost-hover-color | var(--bulma-link) |
--bulma-button-ghost-hover-decoration | $button-ghost-hover-decoration | underline |
--bulma-button-disabled-background-color | $button-disabled-background-color | var(--bulma-scheme-main) |
--bulma-button-disabled-border-color | $button-disabled-border-color | var(--bulma-border) |
--bulma-button-disabled-shadow | $button-disabled-shadow | none |
--bulma-button-disabled-opacity | $button-disabled-opacity | 0.5 |
--bulma-button-static-color | $button-static-color | var(--bulma-text-weak) |
--bulma-button-static-background-color | $button-static-background-color | var(--bulma-scheme-main-ter) |
--bulma-button-static-border-color | $button-static-border-color | var(--bulma-border) |
--bulma-button-h | $button-h | var(--bulma-scheme-h) |
--bulma-button-s | $button-s | var(--bulma-scheme-s) |
--bulma-button-l | $button-l | var(--bulma-scheme-main-l) |
--bulma-button-background-l | $button-background-l | var(--bulma-scheme-main-l) |
--bulma-button-background-l-delta | $button-background-l-delta | 0% |
--bulma-button-hover-background-l-delta | $button-hover-background-l-delta | var(--bulma-hover-background-l-delta) |
--bulma-button-active-background-l-delta | $button-active-background-l-delta | var(--bulma-active-background-l-delta) |
--bulma-button-color-l | $button-color-l | var(--bulma-text-strong-l) |
--bulma-button-border-l | $button-border-l | var(--bulma-border-l) |
--bulma-button-border-l-delta | $button-border-l-delta | 0% |
--bulma-button-hover-border-l-delta | $button-hover-border-l-delta | var(--bulma-hover-border-l-delta) |
--bulma-button-active-border-l-delta | $button-active-border-l-delta | var(--bulma-active-border-l-delta) |
--bulma-button-focus-border-l-delta | $button-focus-border-l-delta | var(--bulma-focus-border-l-delta) |
--bulma-button-outer-shadow-h | $button-outer-shadow-h | 0 |
--bulma-button-outer-shadow-s | $button-outer-shadow-s | 0% |
--bulma-button-outer-shadow-l | $button-outer-shadow-l | 20% |
--bulma-button-outer-shadow-a | $button-outer-shadow-a | 0.05 |
--bulma-loading-color | — | hsl(var(--bulma-button-h), var(--bulma-button-s), var(--bulma-button-color-l)) |