# Primary button

A straightforward primary action with hover, pressed, and disabled states.

## Usage

Use for a primary action. Keep one clear priority per section. This is a button, so use a link for navigation.

Save the JSX and CSS Module in the same folder in a React project with CSS Modules support. Controlled components need parent state and change handlers.

## JSX

```jsx
"use client";
import styles from "./PressButton.module.css";
export default function PressButton({
  children = "Continue",
  onClick,
  disabled = false,
  variant = "solid",
}) {
  return (
    <button
      type="button"
      className={styles.button}
      data-variant={variant}
      disabled={disabled}
      onClick={onClick}
    >
      {children}
    </button>
  );
}

```

## CSS

```css
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: var(--tdp-control-height, 48px);
  padding: 0 20px;
  border: 1px solid var(--tdp-primary, #1f3934);
  border-radius: var(--tdp-radius, 8px);
  background: var(--tdp-primary, #1f3934);
  color: var(--tdp-on-primary, #ffffff);
  font: 500 14px var(--tdp-font, "DM Sans", system-ui, sans-serif);
  box-shadow: none;
  cursor: pointer;
  transition: background 0.15s;
}
.button:hover {
  background: color-mix(in srgb, var(--tdp-primary, #1f3934) 85%, white);
}
.button:active {
  background: color-mix(in srgb, var(--tdp-primary, #1f3934) 90%, black);
}
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.button:focus-visible,
.button :where(button, input, summary):focus-visible {
  outline: 3px solid var(--tdp-focus, #7851a9);
  outline-offset: 4px;
}
@media (prefers-reduced-motion: reduce) {
  .button,
  .button :where(button, input, summary, span) {
    transition: none !important;
    animation: none !important;
  }
}

.button[data-variant="outline"] {
  background: var(--tdp-surface, #fffdfa);
  color: var(--tdp-text, #302e2b);
  border-color: var(--tdp-border, #d9d1c9);
}
.button[data-variant="subtle"] {
  background: transparent;
  color: var(--tdp-text, #302e2b);
  border-color: transparent;
}
.button:is([data-variant="outline"], [data-variant="subtle"]):hover:not(
    :disabled
  ) {
  background: var(--tdp-subtle, #eee8e1);
}
.button:disabled {
  pointer-events: none;
}

```

## Props

- children (ReactNode): Button label. Use an action verb.
- onClick (function): Connect the button to your application action.
- disabled (boolean): Prevents interaction when true.
- variant ("solid" | "outline" | "subtle"): Primary, secondary, or low-emphasis treatment. Defaults to solid.

## Accessibility

A native button supports Enter and Space. Disabled controls are skipped in the tab order; explain why an action is unavailable nearby.

Check accessibility again after customizing the component.

[Browse all components](/resources/components/)

Canonical: https://designproject.io/resources/components/press-button/

## Keep learning

- [How to create a UI color palette, step by step](https://designproject.io/resources/guides/create-ui-color-palette/)
- [Product design glossary: 44 terms explained](https://designproject.io/resources/glossary/)
- [How to choose font pairings for a product interface](https://designproject.io/resources/guides/choose-font-pairings/)
