Skip to main content

Starwind UI v3.0 is now available! Migration guide

Installation

Usage

Button renders a <button> by default. Provide href when the action should navigate to another page.

Variants

Use variant to set the action’s visual emphasis and status.

Sizes

Use size for text buttons and the icon-* sizes for icon-only buttons. Give every icon-only button an accessible name.

Border Radius

Use a Tailwind radius class such as rounded-none or rounded-full to override the default corners.

API Reference

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Button

Inherits a attributes. Omits `type`.

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
as "button" | "a"
Description
Selects the rendered element or component.
Classification
Wrapper prop
focusableWhenDisabled boolean
Description
Keeps the disabled control in the keyboard focus order.
Classification
Primitive override
Primitive prop
button.Root.focusableWhenDisabled
size "sm" | "md" | "lg" | "icon-sm" | "icon" | "icon-lg" "md"
Description
Selects the component's visual size.
Classification
Styled variant
variant "default" | "primary" | "secondary" | "outline" | "ghost" | "info" | "success" | "warning" | "error" "default"
Description
Selects the component's visual variant.
Classification
Styled variant

Primitive And Runtime API

Use these references when you need the lower-level behavior APIs behind Button.

Primitive API

Runtime API

Button primitive
createButton from @starwind-ui/runtime/button

Changelog

View version history v3.0.1 8 releases

v3.0.1

  • Named the generated aggregate default export so React and Astro tooling can identify the installed component cleanly.

v3.0.0

  • Rebuilt Button on Starwind Runtime while preserving styled variants and link rendering.
  • See the Button Primitive for the underlying unstyled anatomy and behavior API.

v2.3.3

  • Refactor tailwind variants functions into separate variants.ts file

v2.3.0

  • Add aria-invalid styling
  • Update styling for SVGs within so it doesn’t override any size-* classes on the SVG itself
  • Update style horizontal padding to more closely match shadcn aspect ratios

v2.2.0

  • add additional sizes “icon-sm” and “icon-lg”
  • style and focus state updates

v2.1.0

  • Add a data-slot attribute to all components to enable global styling updates

v2.0.1

  • Adjust component to use type VariantProps from tailwind-variants. This provides greater type safety and cleans up component frontmatter.

v2.0.0

  • tailwind-variants now implemented. This uses tailwind-merge under the hood to merge Tailwind classes without style conflicts.
  • Removed radius prop now that classes like “rounded-full” can be passed to the components to override, taking advantage of tailwind-variants