Skip to content

Button

Buttons are interactive elements that trigger actions when clicked. They communicate the action that will occur when the user interacts with them.

Usage

Use buttons for actions in forms, dialogs, and more. Buttons can contain text, icons, or both.

Variants

Primary

Primary buttons are for the main action on a page. Use sparingly—typically one per section.

html
<button class="df-button df-button--primary">Primary Button</button>

Secondary

Secondary buttons are for secondary actions that complement the primary action.

html
<button class="df-button df-button--secondary">Secondary Button</button>

Outline

Outline buttons are for less prominent actions or when you need a lighter visual weight.

html
<button class="df-button df-button--outline">Outline Button</button>

Ghost

Ghost buttons are for the least prominent actions, often used in toolbars or navigation.

html
<button class="df-button df-button--ghost">Ghost Button</button>

Sizes

Buttons come in three sizes: small, medium (default), and large.

html
<button class="df-button df-button--primary df-button--sm">Small</button>
<button class="df-button df-button--primary">Medium</button>
<button class="df-button df-button--primary df-button--lg">Large</button>

States

Disabled

Disabled buttons indicate that an action is not currently available.

html
<button class="df-button df-button--primary" disabled>Disabled</button>

Loading

Show a loading state when an action is in progress.

html
<button class="df-button df-button--primary df-button--loading">
  <span class="df-button__spinner"></span>
  Loading...
</button>

With Icons

Buttons can include icons before or after the text.

html
<button class="df-button df-button--primary">
  <svg><!-- icon --></svg>
  Add Item
</button>

Icon-Only Buttons

For icon-only buttons, include an aria-label for accessibility.

html
<button class="df-button df-button--primary df-button--icon" aria-label="Add">
  <svg><!-- icon --></svg>
</button>

Button Groups

Group related buttons together.

html
<div class="df-button-group">
  <button class="df-button df-button--outline">Left</button>
  <button class="df-button df-button--outline">Center</button>
  <button class="df-button df-button--outline">Right</button>
</div>

Full Width

Make buttons span the full width of their container.

html
<button class="df-button df-button--primary df-button--block">
  Full Width Button
</button>

Accessibility

  • Use <button> for actions and <a> for navigation
  • Always provide visible focus states (built-in)
  • Use aria-label for icon-only buttons
  • Ensure sufficient color contrast (WCAG AA)
  • Don't disable buttons without explanation

Best Practices

  • Use clear, action-oriented labels ("Save Changes" not "Submit")
  • Limit primary buttons to one per section
  • Consider the visual hierarchy of actions
  • Provide loading states for async actions

API Reference

Classes

ClassDescription
df-buttonBase button class (required)
df-button--primaryPrimary variant
df-button--secondarySecondary variant
df-button--outlineOutline variant
df-button--ghostGhost variant
df-button--smSmall size
df-button--lgLarge size
df-button--iconIcon-only button
df-button--blockFull-width button
df-button--loadingLoading state

CSS Custom Properties

PropertyDefaultDescription
--df-button-padding-x1.25remHorizontal padding
--df-button-padding-y0.625remVertical padding
--df-button-font-size0.875remFont size
--df-button-font-weight500Font weight
--df-button-radius0.375remBorder radius

Built with care by Everforth