Button
A clickable trigger for form submits, toolbars, and destructive confirms — with thick borders and a shadow it presses into on click.
import { ArrowUpIcon } from "lucide-react"
import { Button } from "@/components/ui/button"The button triggers an action — submit, confirm, delete. Built on the Base UI Button component and styled to the neobrutalist recipe: thick borders, a hard offset shadow, and an active press that pushes the button into it.
Reach for it when:
- Form submits and primary CTAs —
defaultcarries the main action;secondaryandoutlinefor everything beside it. - Toolbars and icon actions — the
iconsizes make square buttons;ButtonGrouplines them up into segmented rows. - Destructive confirms —
destructivefor delete and remove, usually behind a dialog.
Installation#
pnpm dlx shadcn@latest add https://neobrutalism.com/r/base/button.jsonnpx shadcn@latest add https://neobrutalism.com/r/base/button.jsonyarn dlx shadcn@latest add https://neobrutalism.com/r/base/button.jsonbunx --bun shadcn@latest add https://neobrutalism.com/r/base/button.json
Install the following dependencies:
pnpm add @base-ui/reactnpm install @base-ui/reactyarn add @base-ui/reactbun add @base-ui/react
Copy and paste the following code into your project.
import * as React from "react"
import { cva, type VariantProps } from "class-variance-authority"
import { Slot } from "radix-ui"
import { cn } from "@/lib/utils"
const buttonVariants = cva(
cn(
"group/button font-head font-medium inline-flex cursor-pointer items-center justify-center gap-2 rounded whitespace-nowrap select-none transition-all duration-200",
"disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-60",
"focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary aria-invalid:border-destructive",
// Icons keep their own size; we only set a default when none is given so
// Neobrutalism's h-4/size-4 icons aren't overridden.
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
),
{
variants: {
variant: {
default:
"border-2 border-black bg-primary text-primary-foreground shadow-md transition duration-200 hover:-translate-x-0.5 hover:-translate-y-0.5 hover:bg-primary-hover hover:shadow-lg active:translate-x-1 active:translate-y-1 active:shadow-none",
secondary:
"border-2 border-black bg-secondary text-secondary-foreground shadow-md transition duration-200 hover:-translate-x-0.5 hover:-translate-y-0.5 hover:bg-secondary-hover hover:shadow-lg active:translate-x-1 active:translate-y-1 active:shadow-none",
destructive:
"border-2 border-black bg-destructive text-destructive-foreground shadow-md transition duration-200 hover:-translate-x-0.5 hover:-translate-y-0.5 hover:bg-destructive/90 hover:shadow-lg active:translate-x-1 active:translate-y-1 active:shadow-none",
outline:
"border-2 bg-transparent shadow-md transition duration-200 hover:-translate-x-0.5 hover:-translate-y-0.5 hover:shadow-lg active:translate-x-1 active:translate-y-1 active:shadow-none",
ghost: "bg-transparent hover:bg-accent",
link: "bg-transparent hover:underline",
},
size: {
default: "px-4 py-1.5 text-base",
xs: "px-2 py-0.5 text-xs",
sm: "px-3 py-1 text-sm",
lg: "px-6 py-2 text-base lg:px-8 lg:py-3 lg:text-lg",
icon: "p-2",
"icon-xs": "p-1",
"icon-sm": "p-1.5",
"icon-lg": "p-3",
},
},
defaultVariants: {
variant: "default",
size: "default",
},
}
)
function Button({
className,
variant = "default",
size = "default",
asChild = false,
...props
}: React.ComponentProps<"button"> &
VariantProps<typeof buttonVariants> & {
asChild?: boolean
}) {
const Comp = asChild ? Slot.Root : "button"
return (
<Comp
data-slot="button"
data-variant={variant}
data-size={size}
className={cn(buttonVariants({ variant, size, className }))}
{...props}
/>
)
}
export { Button, buttonVariants }
Update the import paths to match your project setup.
Usage#
import { Button } from "@/components/ui/button"<Button variant="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:
You can also enable this during project setup with npx shadcn@latest init --pointer.
@layer base {
button:not(:disabled),
[role="button"]:not(:disabled) {
cursor: pointer;
}
}Examples#
Size#
Use the size prop to change the size of the button.
import { ArrowUpRightIcon } from "lucide-react"
import { Button } from "@/components/ui/button"Default#
import { Button } from "@/components/ui/button"
export function ButtonDefault() {Outline#
import { Button } from "@/components/ui/button"
export function ButtonOutline() {Secondary#
import { Button } from "@/components/ui/button"
export function ButtonSecondary() {Ghost#
import { Button } from "@/components/ui/button"
export function ButtonGhost() {Destructive#
import { Button } from "@/components/ui/button"
export function ButtonDestructive() {Link#
import { Button } from "@/components/ui/button"
export function ButtonLink() {Icon#
import { CircleFadingArrowUpIcon } from "lucide-react"
import { Button } from "@/components/ui/button"With Icon#
Remember to add the data-icon="inline-start" or data-icon="inline-end" attribute to the icon for the correct spacing.
import { IconGitBranch, IconGitFork } from "@tabler/icons-react"
import { Button } from "@/components/ui/button"Rounded#
Use the rounded-full class to make the button rounded.
import { ArrowUpIcon } from "lucide-react"
import { Button } from "@/components/ui/button"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.
import { Button } from "@/components/ui/button"
import { Spinner } from "@/components/ui/spinner"
Button Group#
To create a button group, use the ButtonGroup component. See the Button Group documentation for more details.
"use client"
import * as React from "react"As Link#
You can use the buttonVariants helper to make a link look like a button.
Do not use <Button render={<a />} nativeButton={false} /> for links. The Base UI Button component always applies role="button", which overrides the semantic link role on <a> elements. Use buttonVariants with a plain <a> tag instead.
import { buttonVariants } from "@/components/ui/button"
export function ButtonRender() {RTL#
To enable RTL support in Neobrutalism.com, see the RTL configuration guide.
"use client"
import { ArrowRightIcon, PlusIcon } from "lucide-react"Accessibility#
The button follows the WAI-ARIA Button pattern. It renders a native <button> by default; when render swaps in another element, Base UI wires up role="button", tabindex, and keyboard activation so the replacement behaves like a real button to assistive tech (see the As Link note above for the one case where that role is wrong).
Keyboard interactions:
| Key | Action |
|---|---|
Tab / Shift + Tab | Move focus to / away from the button |
Space / Enter | Activate the button |
API Reference#
Button#
The Button component is a wrapper around the button element that adds a variety of styles and functionality.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "outline" | "ghost" | "destructive" | "secondary" | "link" | "default" |
size | "default" | "xs" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | "default" |