--- layout: layouts/page.njk title: Button description: Displays a button or a component that looks like a button. toc: - label: Usage id: usage - label: Examples id: examples children: - label: Size id: example-size - label: Default id: example-default - label: Outline id: example-outline - label: Secondary id: example-secondary - label: Ghost id: example-ghost - label: Destructive id: example-destructive - label: Link id: example-link - label: Icon id: example-icon - label: With Icon id: example-with-icon - label: Rounded id: example-rounded - label: Spinner id: example-spinner - label: Button Group id: example-button-group - label: RTL id: example-rtl --- {% from "macros/code_preview.njk" import code_preview %} {% from "macros/code_block.njk" import code_block %} {% set code %}{% endset %} {{ code_preview("button", code) }}
You can use one of the btn classes to style a button element:
btn or btn-primary for default/primary buttons.btn-secondary for secondary buttons.btn-destructive for destructive buttons.btn-outline for outline buttons.btn-ghost for ghost buttons.btn-link for link buttons.btn-xs for extra small buttons.btn-sm for small buttons.btn-lg for large buttons.btn-icon for icon buttons. This can be combined with sizes and variants, for example btn-sm-icon-outline or btn-xs-icon-destructive.Button classes are combined into a single class name. Use btn-{variant}, btn-{size}, btn-{size}-{variant}, btn-icon-{variant}, or btn-{size}-icon-{variant}. Do not stack classes like btn-sm btn-outline; use btn-sm-outline instead.
Basecoat follows Tailwind v4's default button cursor behavior and does not force cursor: pointer.
Use size-specific classes to change the size of the button.
Mark inline icons with data-icon="inline-start" or data-icon="inline-end" when the button should use icon-aware spacing.
Use standard Tailwind classes to override the button radius.
To group related buttons, use the Button Group component.
Buttons support right-to-left layouts through logical spacing. Add dir="rtl" to the button or an ancestor. Directional icons should be flipped explicitly.