artisanpack-ui/accessibility

A package for all accessibility functions for ArtisanPack UI.

Installs: 211

Dependents: 3

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

pkg:composer/artisanpack-ui/accessibility

1.1.1 2025-07-01 16:15 UTC

This package is auto-updated.

Last update: 2025-10-01 00:17:07 UTC


README

A PHP package for ensuring web applications meet accessibility standards, particularly for color contrast.

Features

  • Color Contrast Checking: Determine if text colors have sufficient contrast against background colors
  • Accessible Text Color Generation: Generate accessible text colors based on background colors
  • Tailwind CSS Integration: Support for Tailwind CSS color names
  • User Accessibility Settings: Manage user preferences for accessibility features
  • Laravel Integration: Seamless integration with Laravel applications

Installation

You can install the package via Composer:

composer require artisanpack-ui/accessibility

For detailed installation instructions, including Laravel integration, see the Getting Started Guide.

Basic Usage

Color Contrast Utilities

// Check if text should be black or white on a background
$textColor = a11yCSSVarBlackOrWhite('#3b82f6'); // Returns 'black' or 'white'

// Get the hex code for the most accessible text color
$hexColor = a11yGetContrastColor('#3b82f6'); // Returns '#000000' or '#FFFFFF'

// Check if two colors have sufficient contrast
$hasGoodContrast = a11yCheckContrastColor('#3b82f6', '#ffffff'); // Returns true or false

Accessible Color Generator

use ArtisanPackUI\Accessibility\AccessibleColorGenerator;

$generator = new AccessibleColorGenerator();

// Get black or white text color based on background
$textColor = $generator->generateAccessibleTextColor('#3b82f6');

// Generate a tinted/shaded version that's accessible
$tintedColor = $generator->generateAccessibleTextColor('#3b82f6', true);

// Using Tailwind color names
$textColor = $generator->generateAccessibleTextColor('blue-500');

Helper Functions

// Simple usage (black or white)
$textColor = generateAccessibleTextColor('#3b82f6');

// Tinted/shaded version
$tintedColor = generateAccessibleTextColor('#3b82f6', true);

Laravel Facade

use ArtisanPackUI\Accessibility\Facades\A11y;

$textColor = A11y::a11yCSSVarBlackOrWhite('#3b82f6');
$hexColor = A11y::a11yGetContrastColor('#3b82f6');

Documentation

For complete documentation, visit the Documentation Home.

Quick Links

Guides

Reference

Guidelines

Documentation Structure

The documentation is organized into three main sections:

  • Guides: Step-by-step instructions and usage examples
  • Reference: Technical documentation and API references
  • Guidelines: Best practices and development guidelines

Requirements

  • PHP 8.2 or higher
  • Laravel 5.3 or higher (for Laravel integration)

Contributing

As an open source project, this package is open to contributions from anyone. Please read through the contributing guidelines to learn more about how you can contribute to this project.

License

This package is open-sourced software licensed under the GPL-3.0-or-later license.