Skip to content

Button

The Button component is a fundamental interactive element in the GT Design System. It supports multiple variants, sizes, and states to cover various use cases across GT Alumni applications.

Import

tsx
import { Button } from '@gtalumni-la/react';

Basic Usage

tsx
import { Button } from '@gtalumni-la/react';

function MyComponent() {
  return <Button variant="primary">Primary Button</Button>;
}

Variants

The Button component supports three visual variants:

Primary

The primary variant uses GT Gold and should be used for the main action in a section.

tsx
<Button variant="primary">Primary</Button>

Secondary

The secondary variant uses GT Navy and should be used for secondary actions.

tsx
<Button variant="secondary">Secondary</Button>

Outline

The outline variant provides a subtle option with a border and transparent background.

tsx
<Button variant="outline">Outline</Button>

Sizes

The Button component supports three sizes:

Small

tsx
<Button size="sm">Small Button</Button>

Medium (Default)

tsx
<Button size="md">Medium Button</Button>

Large

tsx
<Button size="lg">Large Button</Button>

States

Disabled

tsx
<Button disabled>Disabled Button</Button>

With Icon

tsx
<Button>
  <>
    <span style={{ marginRight: '8px' }}>📧</span>
    Send Email
  </>
</Button>

API Reference

ButtonProps

tsx
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
  children?: React.ReactNode;
  variant?: 'primary' | 'secondary' | 'outline';
  size?: 'sm' | 'md' | 'lg';
}

Props

PropTypeDefaultDescription
childrenReact.ReactNode-The content of the button
variant'primary' | 'secondary' | 'outline''primary'The visual style variant
size'sm' | 'md' | 'lg''md'The size of the button
disabledbooleanfalseWhether the button is disabled
onClick(event: MouseEvent) => void-Click event handler
type'button' | 'submit' | 'reset''button'The button type

All other HTML button attributes are also supported.

Examples

All Variants Together

tsx
<div style={{ display: 'flex', gap: '12px', flexWrap: 'wrap' }}>
  <Button variant="primary">Primary</Button>
  <Button variant="secondary">Secondary</Button>
  <Button variant="outline">Outline</Button>
</div>

All Sizes Together

tsx
<div style={{ display: 'flex', gap: '12px', alignItems: 'center' }}>
  <Button size="sm">Small</Button>
  <Button size="md">Medium</Button>
  <Button size="lg">Large</Button>
</div>

Form Usage

tsx
<form onSubmit={handleSubmit}>
  <Button type="submit" variant="primary">
    Submit Form
  </Button>
  <Button type="button" variant="secondary" onClick={handleCancel}>
    Cancel
  </Button>
</form>

Accessibility

The Button component follows accessibility best practices:

  • Keyboard Navigation: Fully accessible via keyboard (Tab, Enter, Space)
  • Screen Readers: Proper semantic button element with accessible labels
  • Focus Management: Clear focus indicators and logical tab order
  • ARIA Support: Proper ARIA attributes for enhanced screen reader support

Accessibility Guidelines

  • Use descriptive button text that explains the action
  • Avoid using only icons without text labels
  • Ensure sufficient color contrast (automatically handled by design tokens)
  • Test with keyboard navigation and screen readers
tsx
// Good: Descriptive text
<Button>Save Changes</Button>

// Better: With additional context for screen readers
<Button aria-label="Save changes to user profile">
  Save
</Button>

// Best: Icon with text
<Button>
  <SaveIcon aria-hidden="true" />
  Save Changes
</Button>

Design Tokens

The Button component uses the following design tokens:

  • Colors: --gt-color-primary-gold, --gt-color-primary-navy, --gt-color-neutral-white
  • Spacing: --gt-spacing-2, --gt-spacing-3, --gt-spacing-4, --gt-spacing-6
  • Typography: --gt-font-size-sm, --gt-font-size-base, --gt-font-size-lg

Released under the MIT License.