Skip to content
GitHub11 stars

Displays a button or a component that looks like a button.

<div class="flex flex-wrap items-center gap-2 md:flex-row">
    <Button Variant="ButtonVariant.Outline">Button</Button>
    <Button Variant="ButtonVariant.Outline" Size="ButtonSize.Icon" aria-label="Submit">
        <Icon Data="LucideIcons.ArrowUp" />
    </Button>
</div>

Installation

dnx Blazix.Cli add button

Usage

<Button Variant="ButtonVariant.Outline">Button</Button>

Cursor

Tailwind v4 switched from cursor: pointer to cursor: default for the button component.

If you want to keep the cursor: pointer behavior, add the following code to your CSS file:

Styles/theme.css
@layer base {
  button:not(:disabled),
  [role="button"]:not(:disabled) {
    cursor: pointer;
  }
}

Size

Use the Size parameter to change the size of the button.

<div class="flex flex-col items-start gap-8 sm:flex-row">
    <div class="flex items-start gap-2">
        <Button Size="ButtonSize.Xs" Variant="ButtonVariant.Outline">Extra Small</Button>

Default

<Button>Button</Button>

Outline

<Button Variant="ButtonVariant.Outline">Outline</Button>

Secondary

<Button Variant="ButtonVariant.Secondary">Secondary</Button>

Ghost

<Button Variant="ButtonVariant.Ghost">Ghost</Button>

Destructive

<Button Variant="ButtonVariant.Destructive">Destructive</Button>
<Button Variant="ButtonVariant.Link">Link</Button>

Icon

<Button Variant="ButtonVariant.Outline" Size="ButtonSize.Icon" aria-label="Submit"><Icon Data="LucideIcons.CircleFadingArrowUp" /></Button>

With Icon

Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the icon for the correct spacing.

<div class="flex gap-2">
    <Button Variant="ButtonVariant.Outline">
        <Icon Data="LucideIcons.GitBranch" data-icon="inline-start" />

Rounded

Use the rounded-full class to make the button rounded.

<div class="flex gap-2">
    <Button Class="rounded-full">Get Started</Button>
    <Button Variant="ButtonVariant.Outline" Size="ButtonSize.Icon" Class="rounded-full" aria-label="Submit">
        <Icon Data="LucideIcons.ArrowUp" />
    </Button>
</div>

Spinner

Render a <Spinner /> component inside the button to show a loading state. Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the spinner for the correct spacing.

<div class="flex gap-2">
    <Button Variant="ButtonVariant.Outline" Disabled="true">
        <Spinner data-icon="inline-start" />

Button Group

To create a button group, use the ButtonGroup component. See the Button Group documentation for more details.

<ButtonGroup>
    <ButtonGroup Class="hidden sm:flex">
        <Button Variant="ButtonVariant.Outline" Size="ButtonSize.Icon" aria-label="Go Back">

You can use the ButtonVariants.Get helper to make a link look like a button.

Do not render a Button as an <a> for links. A Button that renders anything but a <button> gets role="button", which overrides the link role of <a>. Use ButtonVariants.Get on a plain <a> tag instead.

<a href="#" class="@ButtonVariants.Get(ButtonVariant.Secondary, ButtonSize.Sm)">Login</a>

RTL

To enable RTL support in Blazix, see the RTL configuration guide.

Translated with AI for the demo, so it may have mistakes.

<div class="flex flex-wrap items-center gap-2 md:flex-row">
    <Button Variant="ButtonVariant.Outline">@T.Button</Button>
    <Button Variant="ButtonVariant.Destructive">@T.Delete</Button>

API Reference

Button

ParameterTypeDefault
Render RenderFragment<ButtonRenderProps>? -
NativeButton bool? -
Variant ButtonVariant ButtonVariant.Default
Size ButtonSize ButtonSize.Default
Type ButtonType ButtonType.Button
Disabled bool false
FocusableWhenDisabled bool false
Class string? -
ChildContent RenderFragment? -

Other attributes are passed to the element it renders.

Changelog

2026-11-25 Button type

Type is now a ButtonType enum instead of a string: ButtonType.Button (the default), ButtonType.Submit, or ButtonType.Reset. A Button with no Type now renders type="button", so inside a form it no longer submits. Give the submit button Type="ButtonType.Submit".

Trigger attributes (context.Attributes) carry the same enum, so spreading them onto a Button still works. AlertDialogAction, AttachmentAction, CalendarDayButton, CarouselNext, CarouselPrevious, CodeBlockCopyButton, InputGroupButton and SidebarTrigger take Type too. Update the Blazix.Primitives package, then re-add the components you use with dnx Blazix.Cli add <name> --overwrite.