Skip to main content
The Flux facade provides a convenient static interface to access the FluxManager instance and its methods.

Overview

The Flux facade is a Laravel facade that proxies method calls to the underlying FluxManager class. It provides access to utility methods for managing Flux components, scripts, styles, and more.
use Flux\Flux;

// Example usage
$classes = Flux::classes('bg-white text-gray-900');
$isPro = Flux::pro();

Methods

All methods from the FluxManager class are accessible through this facade.

classes()

Create a class builder instance for constructing CSS class strings.
public function classes($styles = null): ClassBuilder
styles
string|null
default:"null"
Optional CSS classes to initialize the builder with
Returns: ClassBuilder instance Example:
// Create empty class builder
$builder = Flux::classes();

// Create class builder with initial classes
$builder = Flux::classes('bg-white rounded-lg');
$builder->add('shadow-md'); // Chain additional classes

pro()

Check if Flux Pro is installed.
public function pro(): bool
Returns: true if Flux Pro is installed, false otherwise Example:
if (Flux::pro()) {
    // Flux Pro features available
}

scripts()

Generate the Flux JavaScript script tag.
public function scripts($options = []): string
options
array
default:"[]"
Configuration options for the script tagOptions:
  • nonce (string): CSP nonce value for the script tag
Returns: HTML script tag string Example:
// Basic usage
echo Flux::scripts();

// With CSP nonce
echo Flux::scripts(['nonce' => 'xyz123']);

fluxAppearance()

Generate the Flux appearance management script and styles.
public function fluxAppearance($options = []): string
options
array
default:"[]"
Configuration optionsOptions:
  • nonce (string): CSP nonce value for inline scripts and styles
Returns: HTML string containing inline styles and scripts for appearance management Example:
// Basic usage
echo Flux::fluxAppearance();

// With CSP nonce
echo Flux::fluxAppearance(['nonce' => 'xyz123']);

editorStyles()

Generate the Flux editor CSS link tag (Flux Pro only).
public function editorStyles(): string
Returns: HTML link tag for editor CSS Example:
echo Flux::editorStyles();

editorScripts()

Generate the Flux editor JavaScript script tag (Flux Pro only).
public function editorScripts(): string
Returns: HTML script tag for editor JavaScript Example:
echo Flux::editorScripts();

splitAttributes()

Split an attribute bag into two bags based on attribute names.
public function splitAttributes(
    $attributes, 
    $by = ['class', 'style'], 
    $strict = false
): array
attributes
ComponentAttributeBag
required
The attribute bag to split
by
array
default:"['class', 'style']"
Array of attribute names to split by
strict
bool
default:"false"
If true, uses exact matching. If false, uses startsWith matching
Returns: Array with two ComponentAttributeBag instances: [matched, unmatched] Example:
// Split class and style attributes from others
[$styling, $remaining] = Flux::splitAttributes($attributes);

// Strict matching for specific attributes
[$id, $others] = Flux::splitAttributes($attributes, ['id'], true);

forwardedAttributes()

Extract specific attributes from an attribute bag for forwarding to nested components.
public function forwardedAttributes($attributes, $propKeys): array
attributes
ComponentAttributeBag
required
The attribute bag to extract from
propKeys
array
required
Array of prop keys to extract (supports both camelCase and kebab-case)
Returns: Array of extracted prop values Example:
$props = Flux::forwardedAttributes($attributes, ['wireModel', 'placeholder']);

componentExists()

Check if a Flux component exists.
public function componentExists($name): bool
name
string
required
The component name to check
Returns: true if the component exists, false otherwise Example:
if (Flux::componentExists('button')) {
    // Component exists
}