effects

Shadow, opacity and other visual effect utilities for Tailwind CSS

Box Shadow

Utilities for controlling the box shadow of an element. Box shadows in Tailwind CSS v4 support both shadow size and shadow color customization.

Shadow Size

Define the available shadow sizes from smallest to largest:

Exported source
# Shadow size
SHADOW_SIZE_CONFIG = ScaleConfig(
    numeric=False,
    decimals=False,
    fractions=False,
    named=[
        NamedScale("none", "0", "0 #0000"),
        NamedScale("2xs", "--shadow-2xs", "0 1px rgb(0 0 0 / 0.05)"),
        NamedScale("xs", "--shadow-xs", "0 1px 2px 0 rgb(0 0 0 / 0.05)"),
        NamedScale("sm", "--shadow-sm", "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)"),
        NamedScale("md", "--shadow-md", "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)"),
        NamedScale("lg", "--shadow-lg", "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)"),
        NamedScale("xl", "--shadow-xl", "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)"),
        NamedScale("2xl", "--shadow-2xl", "0 25px 50px -12px rgb(0 0 0 / 0.25)"),
    ],
    special={},
    negative=False
)

shadow = ScaledFactory("shadow", SHADOW_SIZE_CONFIG, "Box shadow utilities for adding depth to elements") # Box shadow factory

Shadow Color

Control the color of shadows using the standard color palette:

Exported source
shadow_color = ColoredFactory("shadow", "Shadow color utilities for customizing the color of box shadows") # Create shadow color factory using the existing ColoredFactory

Test Shadow Utilities

Test the shadow size utilities:


test_effects_shadow_base_examples


def test_effects_shadow_base_examples(
    
):

Test shadow size utilities.

Exported source
def test_effects_shadow_base_examples():
    """Test shadow size utilities."""
    assert str(shadow()) == "shadow"

# Run the tests
test_effects_shadow_base_examples()

test_effects_shadow_size_examples


def test_effects_shadow_size_examples(
    
):

Test shadow size utilities.

Exported source
def test_effects_shadow_size_examples():
    """Test shadow size utilities."""
    assert str(shadow()) == "shadow"
    # Test all named sizes
    assert str(shadow._2xs) == "shadow-2xs"
    assert str(shadow.xs) == "shadow-xs"
    assert str(shadow.sm) == "shadow-sm"
    assert str(shadow.md) == "shadow-md"
    assert str(shadow.lg) == "shadow-lg"
    assert str(shadow.xl) == "shadow-xl"
    assert str(shadow._2xl) == "shadow-2xl"
    assert str(shadow.none) == "shadow-none"
    
    # Test default shadow (no size)
    assert str(shadow()) == "shadow"
    
    # Test with size parameter
    assert str(shadow("sm")) == "shadow-sm"
    assert str(shadow("lg")) == "shadow-lg"
    assert str(shadow("none")) == "shadow-none"

# Run the tests
test_effects_shadow_size_examples()

test_effects_shadow_arbitrary_examples


def test_effects_shadow_arbitrary_examples(
    
):

Test shadow utilities with arbitrary and custom values.

Exported source
def test_effects_shadow_arbitrary_examples():
    """Test shadow utilities with arbitrary and custom values."""
    # Test arbitrary shadow values
    assert str(shadow("10px 10px 5px gray")) == "shadow-[10px 10px 5px gray]"
    assert str(shadow("0 4px 6px rgba(0,0,0,0.1)")) == "shadow-[0 4px 6px rgba(0,0,0,0.1)]"
    assert str(shadow("inset 0 2px 4px rgba(0,0,0,0.06)")) == "shadow-[inset 0 2px 4px rgba(0,0,0,0.06)]"
    
    # Test CSS custom properties
    assert str(shadow("--custom-shadow")) == "shadow-(--custom-shadow)"
    assert str(shadow("--elevation-high")) == "shadow-(--elevation-high)"

# Run the tests  
test_effects_shadow_arbitrary_examples()

Test Shadow Color Utilities

Test the shadow color utilities:


test_effects_shadow_color_examples


def test_effects_shadow_color_examples(
    
):

Test shadow color utilities with various color values.

Exported source
def test_effects_shadow_color_examples():
    """Test shadow color utilities with various color values."""
    # Test all 22 Tailwind color families
    assert str(shadow_color.red._500) == "shadow-red-500"
    assert str(shadow_color.orange._500) == "shadow-orange-500"
    assert str(shadow_color.amber._500) == "shadow-amber-500"
    assert str(shadow_color.yellow._500) == "shadow-yellow-500"
    assert str(shadow_color.lime._500) == "shadow-lime-500"
    assert str(shadow_color.green._500) == "shadow-green-500"
    assert str(shadow_color.emerald._500) == "shadow-emerald-500"
    assert str(shadow_color.teal._500) == "shadow-teal-500"
    assert str(shadow_color.cyan._500) == "shadow-cyan-500"
    assert str(shadow_color.sky._500) == "shadow-sky-500"
    assert str(shadow_color.blue._500) == "shadow-blue-500"
    assert str(shadow_color.indigo._500) == "shadow-indigo-500"
    assert str(shadow_color.violet._500) == "shadow-violet-500"
    assert str(shadow_color.purple._500) == "shadow-purple-500"
    assert str(shadow_color.fuchsia._500) == "shadow-fuchsia-500"
    assert str(shadow_color.pink._500) == "shadow-pink-500"
    assert str(shadow_color.rose._500) == "shadow-rose-500"
    assert str(shadow_color.slate._500) == "shadow-slate-500"
    assert str(shadow_color.gray._500) == "shadow-gray-500"
    assert str(shadow_color.zinc._500) == "shadow-zinc-500"
    assert str(shadow_color.neutral._500) == "shadow-neutral-500"
    assert str(shadow_color.stone._500) == "shadow-stone-500"
    
    # Test different shades
    assert str(shadow_color.blue._300) == "shadow-blue-300"
    assert str(shadow_color.green._950) == "shadow-green-950"
    
    # Special colors
    assert str(shadow_color.transparent) == "shadow-transparent"
    assert str(shadow_color.black) == "shadow-black"
    assert str(shadow_color.white) == "shadow-white"
    assert str(shadow_color.current) == "shadow-current"
    assert str(shadow_color.inherit) == "shadow-inherit"

# Run the tests
test_effects_shadow_color_examples()

test_effects_shadow_color_arbitrary_examples


def test_effects_shadow_color_arbitrary_examples(
    
):

Test shadow color utilities with arbitrary values.

Exported source
def test_effects_shadow_color_arbitrary_examples():
    """Test shadow color utilities with arbitrary values."""
    # Test hex colors
    assert str(shadow_color("#ff0000")) == "shadow-[#ff0000]"
    assert str(shadow_color("#123456")) == "shadow-[#123456]"
    
    # Test RGB/RGBA colors
    assert str(shadow_color("rgb(255, 0, 0)")) == "shadow-[rgb(255, 0, 0)]"
    assert str(shadow_color("rgba(0, 0, 0, 0.5)")) == "shadow-[rgba(0, 0, 0, 0.5)]"
    
    # Test CSS custom properties
    assert str(shadow_color("--shadow-color-primary")) == "shadow-(--shadow-color-primary)"
    assert str(shadow_color("--brand-shadow")) == "shadow-(--brand-shadow)"

# Run the tests
test_effects_shadow_color_arbitrary_examples()

Inset Shadow

Utilities for controlling inset box shadows. These shadows appear inside the element rather than outside.

Inset Shadow Size

Define the inset shadow size configuration:

Exported source
# Inset shadow size
INSET_SHADOW_SIZE_CONFIG = ScaleConfig(
    numeric=False,
    decimals=False,
    fractions=False,
    named=[
        NamedScale("none", "0", "inset 0 0 #0000"),
        NamedScale("2xs", "--inset-shadow-2xs", "inset 0 1px rgb(0 0 0 / 0.05)"),
        NamedScale("xs", "--inset-shadow-xs", "inset 0 1px 1px rgb(0 0 0 / 0.05)"),
        NamedScale("sm", "--inset-shadow-sm", "inset 0 2px 4px rgb(0 0 0 / 0.05)"),
    ],
    special={},
    negative=False
)

inset_shadow = ScaledFactory("inset-shadow", INSET_SHADOW_SIZE_CONFIG, "Inset box shadow utilities for adding inner depth to elements") # Inset box shadow factory

Inset Shadow Color

Control the color of inset shadows using the standard color palette:

Exported source
inset_shadow_color = ColoredFactory("inset-shadow", "Inset shadow color utilities for customizing the color of inner box shadows") # Create inset shadow color factory using the existing ColoredFactory

Test Inset Shadow Utilities

Test the inset shadow size utilities:


test_effects_inset_shadow_size_examples


def test_effects_inset_shadow_size_examples(
    
):

Test inset shadow size utilities.

Exported source
def test_effects_inset_shadow_size_examples():
    """Test inset shadow size utilities."""
    # Test all named sizes
    assert str(inset_shadow._2xs) == "inset-shadow-2xs"
    assert str(inset_shadow.xs) == "inset-shadow-xs"
    assert str(inset_shadow.sm) == "inset-shadow-sm"
    assert str(inset_shadow.none) == "inset-shadow-none"
    
    # Test default inset shadow (no default)
    assert str(inset_shadow()) == "inset-shadow"
    
    # Test with size parameter
    assert str(inset_shadow.xs) == "inset-shadow-xs"
    assert str(inset_shadow._2xs) == "inset-shadow-2xs"
    assert str(inset_shadow.none) == "inset-shadow-none"

# Run the tests
test_effects_inset_shadow_size_examples()

test_effects_inset_shadow_arbitrary_examples


def test_effects_inset_shadow_arbitrary_examples(
    
):

Test inset shadow utilities with arbitrary and custom values.

Exported source
def test_effects_inset_shadow_arbitrary_examples():
    """Test inset shadow utilities with arbitrary and custom values."""
    # Test arbitrary inset shadow values
    assert str(inset_shadow("inset 0 2px 4px rgba(0,0,0,0.06)")) == "inset-shadow-[inset 0 2px 4px rgba(0,0,0,0.06)]"
    assert str(inset_shadow("inset 0 1px 3px rgba(0,0,0,0.12)")) == "inset-shadow-[inset 0 1px 3px rgba(0,0,0,0.12)]"
    
    # Test CSS custom properties
    assert str(inset_shadow("--custom-inset-shadow")) == "inset-shadow-(--custom-inset-shadow)"
    assert str(inset_shadow("--inner-glow")) == "inset-shadow-(--inner-glow)"

# Run the tests  
test_effects_inset_shadow_arbitrary_examples()

Test Inset Shadow Color Utilities

Test the inset shadow color utilities:


test_effects_inset_shadow_color_examples


def test_effects_inset_shadow_color_examples(
    
):

Test inset shadow color utilities with various color values.

Exported source
def test_effects_inset_shadow_color_examples():
    """Test inset shadow color utilities with various color values."""
    # Test standard color families
    assert str(inset_shadow_color.red._500) == "inset-shadow-red-500"
    assert str(inset_shadow_color.blue._300) == "inset-shadow-blue-300"
    assert str(inset_shadow_color.green._950) == "inset-shadow-green-950"
    assert str(inset_shadow_color.purple._600) == "inset-shadow-purple-600"

    # Test all 22 Tailwind color families
    assert str(inset_shadow_color.red._500) == "inset-shadow-red-500"
    assert str(inset_shadow_color.orange._500) == "inset-shadow-orange-500"
    assert str(inset_shadow_color.amber._500) == "inset-shadow-amber-500"
    assert str(inset_shadow_color.yellow._500) == "inset-shadow-yellow-500"
    assert str(inset_shadow_color.lime._500) == "inset-shadow-lime-500"
    assert str(inset_shadow_color.green._500) == "inset-shadow-green-500"
    assert str(inset_shadow_color.emerald._500) == "inset-shadow-emerald-500"
    assert str(inset_shadow_color.teal._500) == "inset-shadow-teal-500"
    assert str(inset_shadow_color.cyan._500) == "inset-shadow-cyan-500"
    assert str(inset_shadow_color.sky._500) == "inset-shadow-sky-500"
    assert str(inset_shadow_color.blue._500) == "inset-shadow-blue-500"
    assert str(inset_shadow_color.indigo._500) == "inset-shadow-indigo-500"
    assert str(inset_shadow_color.violet._500) == "inset-shadow-violet-500"
    assert str(inset_shadow_color.purple._500) == "inset-shadow-purple-500"
    assert str(inset_shadow_color.fuchsia._500) == "inset-shadow-fuchsia-500"
    assert str(inset_shadow_color.pink._500) == "inset-shadow-pink-500"
    assert str(inset_shadow_color.rose._500) == "inset-shadow-rose-500"
    assert str(inset_shadow_color.slate._500) == "inset-shadow-slate-500"
    assert str(inset_shadow_color.gray._500) == "inset-shadow-gray-500"
    assert str(inset_shadow_color.zinc._500) == "inset-shadow-zinc-500"
    assert str(inset_shadow_color.neutral._500) == "inset-shadow-neutral-500"
    assert str(inset_shadow_color.stone._500) == "inset-shadow-stone-500"
    
    # Special colors
    assert str(inset_shadow_color.transparent) == "inset-shadow-transparent"
    assert str(inset_shadow_color.black) == "inset-shadow-black"
    assert str(inset_shadow_color.white) == "inset-shadow-white"
    assert str(inset_shadow_color.current) == "inset-shadow-current"
    assert str(inset_shadow_color.inherit) == "inset-shadow-inherit"
    
    # Test with arbitrary colors
    assert str(inset_shadow_color("#ff0000")) == "inset-shadow-[#ff0000]"
    assert str(inset_shadow_color("rgba(0, 0, 0, 0.5)")) == "inset-shadow-[rgba(0, 0, 0, 0.5)]"
    
    # Test CSS custom properties
    assert str(inset_shadow_color("--inset-shadow-primary")) == "inset-shadow-(--inset-shadow-primary)"

# Run the tests
test_effects_inset_shadow_color_examples()

Ring

Utilities for creating outline rings around elements. These are commonly used for focus states.

Ring Width

Define the ring width configuration:

Exported source
# Ring width configuration
RING_WIDTH_CONFIG = ScaleConfig(
    numeric=True,  # Support numeric widths (0, 1, 2, 4, 8, etc.)
    decimals=False,
    fractions=False,
    named=[],
    special={},
    negative=False
)

ring = ScaledFactory("ring", RING_WIDTH_CONFIG, "Ring (outline) utilities for adding focus rings and outlines to elements") # Ring width factory

Ring Color

Control the color of rings using the standard color palette:

Exported source
ring_color = ColoredFactory("ring", "Ring color utilities for customizing the color of focus rings and outlines") # Create ring color factory using the existing ColoredFactory

Test Ring Utilities

Test the ring width utilities:


test_effects_ring_width_examples


def test_effects_ring_width_examples(
    
):

Test ring width utilities.

Exported source
def test_effects_ring_width_examples():
    """Test ring width utilities."""
    # Test default ring
    assert str(ring()) == "ring"
    
    # Test common widths
    assert str(ring(0)) == "ring-0"
    assert str(ring(1)) == "ring-1"
    assert str(ring(2)) == "ring-2"
    assert str(ring(4)) == "ring-4"
    assert str(ring(8)) == "ring-8"
    
    # Test with width parameter
    assert str(ring(0)) == "ring-0"
    assert str(ring(2)) == "ring-2"
    assert str(ring(4)) == "ring-4"
    assert str(ring(16)) == "ring-16"
    
    # Test arbitrary values
    assert str(ring("3px")) == "ring-[3px]"
    assert str(ring("0.5rem")) == "ring-[0.5rem]"
    
    # Test CSS custom properties
    assert str(ring("--ring-width")) == "ring-(--ring-width)"
    assert str(ring("--focus-ring")) == "ring-(--focus-ring)"

# Run the tests
test_effects_ring_width_examples()

Test Ring Color Utilities

Test the ring color utilities:


test_effects_ring_color_examples


def test_effects_ring_color_examples(
    
):

Test ring color utilities with various color values.

Exported source
def test_effects_ring_color_examples():
    """Test ring color utilities with various color values."""
    # Test standard color families
    assert str(ring_color.red._500) == "ring-red-500"
    assert str(ring_color.blue._300) == "ring-blue-300"
    assert str(ring_color.green._950) == "ring-green-950"
    assert str(ring_color.purple._600) == "ring-purple-600"

    # Test all 22 Tailwind color families
    assert str(ring_color.red._500) == "ring-red-500"
    assert str(ring_color.orange._500) == "ring-orange-500"
    assert str(ring_color.amber._500) == "ring-amber-500"
    assert str(ring_color.yellow._500) == "ring-yellow-500"
    assert str(ring_color.lime._500) == "ring-lime-500"
    assert str(ring_color.green._500) == "ring-green-500"
    assert str(ring_color.emerald._500) == "ring-emerald-500"
    assert str(ring_color.teal._500) == "ring-teal-500"
    assert str(ring_color.cyan._500) == "ring-cyan-500"
    assert str(ring_color.sky._500) == "ring-sky-500"
    assert str(ring_color.blue._500) == "ring-blue-500"
    assert str(ring_color.indigo._500) == "ring-indigo-500"
    assert str(ring_color.violet._500) == "ring-violet-500"
    assert str(ring_color.purple._500) == "ring-purple-500"
    assert str(ring_color.fuchsia._500) == "ring-fuchsia-500"
    assert str(ring_color.pink._500) == "ring-pink-500"
    assert str(ring_color.rose._500) == "ring-rose-500"
    assert str(ring_color.slate._500) == "ring-slate-500"
    assert str(ring_color.gray._500) == "ring-gray-500"
    assert str(ring_color.zinc._500) == "ring-zinc-500"
    assert str(ring_color.neutral._500) == "ring-neutral-500"
    assert str(ring_color.stone._500) == "ring-stone-500"
    
    # Special colors
    assert str(ring_color.transparent) == "ring-transparent"
    assert str(ring_color.black) == "ring-black"
    assert str(ring_color.white) == "ring-white"
    assert str(ring_color.current) == "ring-current"
    assert str(ring_color.inherit) == "ring-inherit"
    
    # Test with arbitrary colors
    assert str(ring_color("#ff0000")) == "ring-[#ff0000]"
    assert str(ring_color("rgba(0, 0, 255, 0.5)")) == "ring-[rgba(0, 0, 255, 0.5)]"
    
    # Test CSS custom properties
    assert str(ring_color("--ring-primary")) == "ring-(--ring-primary)"

# Run the tests
test_effects_ring_color_examples()

Inset Ring

Utilities for creating inset (inner) outline rings. These appear inside the element rather than outside.

Inset Ring Width

Define the inset ring width configuration:

Exported source
# Inset ring width configuration (same as ring width)
INSET_RING_WIDTH_CONFIG = ScaleConfig(
    numeric=True,  # Support numeric widths (0, 1, 2, 4, 8, etc.)
    decimals=False,
    fractions=False,
    named=[],
    special={},
    negative=False
)

inset_ring = ScaledFactory("inset-ring", INSET_RING_WIDTH_CONFIG, "Inset ring (inner outline) utilities for adding inner focus rings and outlines to elements") # Inset ring width factory

Inset Ring Color

Control the color of inset rings using the standard color palette:

Exported source
inset_ring_color = ColoredFactory("inset-ring", "Inset ring color utilities for customizing the color of inner focus rings and outlines") # Create inset ring color factory using the existing ColoredFactory

Test Inset Ring Utilities

Test the inset ring width utilities:


test_effects_inset_ring_width_examples


def test_effects_inset_ring_width_examples(
    
):

Test inset ring width utilities.

Exported source
def test_effects_inset_ring_width_examples():
    """Test inset ring width utilities."""
    # Test default inset ring
    assert str(inset_ring()) == "inset-ring"
    
    # Test common widths
    assert str(inset_ring(0)) == "inset-ring-0"
    assert str(inset_ring(1)) == "inset-ring-1"
    assert str(inset_ring(2)) == "inset-ring-2"
    assert str(inset_ring(4)) == "inset-ring-4"
    assert str(inset_ring(8)) == "inset-ring-8"
    
    # Test with width parameter
    assert str(inset_ring(0)) == "inset-ring-0"
    assert str(inset_ring(2)) == "inset-ring-2"
    assert str(inset_ring(4)) == "inset-ring-4"
    assert str(inset_ring(16)) == "inset-ring-16"
    
    # Test arbitrary values
    assert str(inset_ring("3px")) == "inset-ring-[3px]"
    assert str(inset_ring("0.25rem")) == "inset-ring-[0.25rem]"
    
    # Test CSS custom properties
    assert str(inset_ring("--inset-ring-width")) == "inset-ring-(--inset-ring-width)"
    assert str(inset_ring("--inner-focus-ring")) == "inset-ring-(--inner-focus-ring)"

# Run the tests
test_effects_inset_ring_width_examples()

Test Inset Ring Color Utilities

Test the inset ring color utilities:


test_effects_inset_ring_color_examples


def test_effects_inset_ring_color_examples(
    
):

Test inset ring color utilities with various color values.

Exported source
def test_effects_inset_ring_color_examples():
    """Test inset ring color utilities with various color values."""
    # Test standard color families
    assert str(inset_ring_color.red._500) == "inset-ring-red-500"
    assert str(inset_ring_color.blue._300) == "inset-ring-blue-300"
    assert str(inset_ring_color.green._950) == "inset-ring-green-950"
    assert str(inset_ring_color.purple._600) == "inset-ring-purple-600"

    # Test all 22 Tailwind color families
    assert str(inset_ring_color.red._500) == "inset-ring-red-500"
    assert str(inset_ring_color.orange._500) == "inset-ring-orange-500"
    assert str(inset_ring_color.amber._500) == "inset-ring-amber-500"
    assert str(inset_ring_color.yellow._500) == "inset-ring-yellow-500"
    assert str(inset_ring_color.lime._500) == "inset-ring-lime-500"
    assert str(inset_ring_color.green._500) == "inset-ring-green-500"
    assert str(inset_ring_color.emerald._500) == "inset-ring-emerald-500"
    assert str(inset_ring_color.teal._500) == "inset-ring-teal-500"
    assert str(inset_ring_color.cyan._500) == "inset-ring-cyan-500"
    assert str(inset_ring_color.sky._500) == "inset-ring-sky-500"
    assert str(inset_ring_color.blue._500) == "inset-ring-blue-500"
    assert str(inset_ring_color.indigo._500) == "inset-ring-indigo-500"
    assert str(inset_ring_color.violet._500) == "inset-ring-violet-500"
    assert str(inset_ring_color.purple._500) == "inset-ring-purple-500"
    assert str(inset_ring_color.fuchsia._500) == "inset-ring-fuchsia-500"
    assert str(inset_ring_color.pink._500) == "inset-ring-pink-500"
    assert str(inset_ring_color.rose._500) == "inset-ring-rose-500"
    assert str(inset_ring_color.slate._500) == "inset-ring-slate-500"
    assert str(inset_ring_color.gray._500) == "inset-ring-gray-500"
    assert str(inset_ring_color.zinc._500) == "inset-ring-zinc-500"
    assert str(inset_ring_color.neutral._500) == "inset-ring-neutral-500"
    assert str(inset_ring_color.stone._500) == "inset-ring-stone-500"
    
    # Special colors
    assert str(inset_ring_color.transparent) == "inset-ring-transparent"
    assert str(inset_ring_color.black) == "inset-ring-black"
    assert str(inset_ring_color.white) == "inset-ring-white"
    assert str(inset_ring_color.current) == "inset-ring-current"
    assert str(inset_ring_color.inherit) == "inset-ring-inherit"
    
    # Test with arbitrary colors
    assert str(inset_ring_color("#0000ff")) == "inset-ring-[#0000ff]"
    assert str(inset_ring_color("rgba(255, 0, 0, 0.8)")) == "inset-ring-[rgba(255, 0, 0, 0.8)]"
    
    # Test CSS custom properties
    assert str(inset_ring_color("--inset-ring-primary")) == "inset-ring-(--inset-ring-primary)"

# Run the tests
test_effects_inset_ring_color_examples()

Text Shadow

Utilities for controlling the shadow of a text element. Text shadows in Tailwind CSS v4 support both shadow size and shadow color customization.

Text Shadow Size

Define the text shadow size configuration:

Exported source
# Text shadow size
TEXT_SHADOW_SIZE_CONFIG = ScaleConfig(
    numeric=False,
    decimals=False,
    fractions=False,
    named=[
        NamedScale("none", "0", "none"),
        NamedScale("2xs", "--text-shadow-2xs", "0px 1px 0px rgb(0 0 0 / 0.15)"),
        NamedScale("xs", "--text-shadow-xs", "0px 1px 1px rgb(0 0 0 / 0.2)"),
        NamedScale("sm", "--text-shadow-sm", "0px 1px 0px rgb(0 0 0 / 0.075), 0px 1px 1px rgb(0 0 0 / 0.075), 0px 2px 2px rgb(0 0 0 / 0.075)"),
        NamedScale("md", "--text-shadow-md", "0px 1px 1px rgb(0 0 0 / 0.1), 0px 1px 2px rgb(0 0 0 / 0.1), 0px 2px 4px rgb(0 0 0 / 0.1)"),
        NamedScale("lg", "--text-shadow-lg", "0px 1px 2px rgb(0 0 0 / 0.1), 0px 3px 2px rgb(0 0 0 / 0.1), 0px 4px 8px rgb(0 0 0 / 0.1)"),
    ],
    special={},
    negative=False
)

text_shadow = ScaledFactory("text-shadow", TEXT_SHADOW_SIZE_CONFIG, "Text shadow utilities for adding shadows to text") # Text shadow factory

Text Shadow Color

Control the color of text shadows using the standard color palette:

Exported source
text_shadow_color = ColoredFactory("text-shadow", "Text shadow color utilities for customizing the color of text shadows") # Create text shadow color factory using the existing ColoredFactory

Test Text Shadow Utilities

Test the text shadow size utilities:


test_effects_text_shadow_size_examples


def test_effects_text_shadow_size_examples(
    
):

Test text shadow size utilities.

Exported source
def test_effects_text_shadow_size_examples():
    """Test text shadow size utilities."""
    # Test all named sizes
    assert str(text_shadow._2xs) == "text-shadow-2xs"
    assert str(text_shadow.xs) == "text-shadow-xs"
    assert str(text_shadow.sm) == "text-shadow-sm"
    assert str(text_shadow.md) == "text-shadow-md"
    assert str(text_shadow.lg) == "text-shadow-lg"
    assert str(text_shadow.none) == "text-shadow-none"
    
    # Test default text shadow (no size)
    assert str(text_shadow()) == "text-shadow"
    
    # Test with size parameter
    assert str(text_shadow("sm")) == "text-shadow-sm"
    assert str(text_shadow("lg")) == "text-shadow-lg"
    assert str(text_shadow("none")) == "text-shadow-none"

# Run the tests
test_effects_text_shadow_size_examples()

test_effects_text_shadow_arbitrary_examples


def test_effects_text_shadow_arbitrary_examples(
    
):

Test text shadow utilities with arbitrary and custom values.

Exported source
def test_effects_text_shadow_arbitrary_examples():
    """Test text shadow utilities with arbitrary and custom values."""
    # Test arbitrary text shadow values
    assert str(text_shadow("2px 2px 4px rgba(0,0,0,0.5)")) == "text-shadow-[2px 2px 4px rgba(0,0,0,0.5)]"
    assert str(text_shadow("1px 1px 2px black")) == "text-shadow-[1px 1px 2px black]"
    assert str(text_shadow("0 0 10px #ff0000")) == "text-shadow-[0 0 10px #ff0000]"
    
    # Test CSS custom properties
    assert str(text_shadow("--custom-text-shadow")) == "text-shadow-(--custom-text-shadow)"
    assert str(text_shadow("--heading-shadow")) == "text-shadow-(--heading-shadow)"

# Run the tests  
test_effects_text_shadow_arbitrary_examples()

Test Text Shadow Color Utilities

Test the text shadow color utilities:


test_effects_text_shadow_color_examples


def test_effects_text_shadow_color_examples(
    
):

Test text shadow color utilities with various color values.

Exported source
def test_effects_text_shadow_color_examples():
    """Test text shadow color utilities with various color values."""
    # Test all 22 Tailwind color families
    assert str(text_shadow_color.red._500) == "text-shadow-red-500"
    assert str(text_shadow_color.orange._500) == "text-shadow-orange-500"
    assert str(text_shadow_color.amber._500) == "text-shadow-amber-500"
    assert str(text_shadow_color.yellow._500) == "text-shadow-yellow-500"
    assert str(text_shadow_color.lime._500) == "text-shadow-lime-500"
    assert str(text_shadow_color.green._500) == "text-shadow-green-500"
    assert str(text_shadow_color.emerald._500) == "text-shadow-emerald-500"
    assert str(text_shadow_color.teal._500) == "text-shadow-teal-500"
    assert str(text_shadow_color.cyan._500) == "text-shadow-cyan-500"
    assert str(text_shadow_color.sky._500) == "text-shadow-sky-500"
    assert str(text_shadow_color.blue._500) == "text-shadow-blue-500"
    assert str(text_shadow_color.indigo._500) == "text-shadow-indigo-500"
    assert str(text_shadow_color.violet._500) == "text-shadow-violet-500"
    assert str(text_shadow_color.purple._500) == "text-shadow-purple-500"
    assert str(text_shadow_color.fuchsia._500) == "text-shadow-fuchsia-500"
    assert str(text_shadow_color.pink._500) == "text-shadow-pink-500"
    assert str(text_shadow_color.rose._500) == "text-shadow-rose-500"
    assert str(text_shadow_color.slate._500) == "text-shadow-slate-500"
    assert str(text_shadow_color.gray._500) == "text-shadow-gray-500"
    assert str(text_shadow_color.zinc._500) == "text-shadow-zinc-500"
    assert str(text_shadow_color.neutral._500) == "text-shadow-neutral-500"
    assert str(text_shadow_color.stone._500) == "text-shadow-stone-500"
    
    # Test different shades
    assert str(text_shadow_color.blue._300) == "text-shadow-blue-300"
    assert str(text_shadow_color.green._950) == "text-shadow-green-950"
    
    # Special colors
    assert str(text_shadow_color.transparent) == "text-shadow-transparent"
    assert str(text_shadow_color.black) == "text-shadow-black"
    assert str(text_shadow_color.white) == "text-shadow-white"
    assert str(text_shadow_color.current) == "text-shadow-current"
    assert str(text_shadow_color.inherit) == "text-shadow-inherit"

# Run the tests
test_effects_text_shadow_color_examples()

Opacity

Utilities for controlling the opacity of an element. Opacity values range from 0 (fully transparent) to 100 (fully opaque).

Exported source
# Opacity configuration - support percentage values (0-100)
OPACITY_CONFIG = ScaleConfig(
    numeric=True,  # Support numeric values 0-100
    decimals=False,
    fractions=False,
    named=[],
    special={},
    negative=False
)

opacity = ScaledFactory("opacity", OPACITY_CONFIG, "Opacity utilities for controlling element transparency") # Opacity factory

Test Opacity Utilities

Test the opacity utilities:


test_effects_opacity_examples


def test_effects_opacity_examples(
    
):

Test opacity utilities with various values.

Exported source
def test_effects_opacity_examples():
    """Test opacity utilities with various values."""
    # Test common opacity values
    assert str(opacity(0)) == "opacity-0"
    assert str(opacity(5)) == "opacity-5"
    assert str(opacity(10)) == "opacity-10"
    assert str(opacity(20)) == "opacity-20"
    assert str(opacity(25)) == "opacity-25"
    assert str(opacity(30)) == "opacity-30"
    assert str(opacity(40)) == "opacity-40"
    assert str(opacity(50)) == "opacity-50"
    assert str(opacity(60)) == "opacity-60"
    assert str(opacity(70)) == "opacity-70"
    assert str(opacity(75)) == "opacity-75"
    assert str(opacity(80)) == "opacity-80"
    assert str(opacity(90)) == "opacity-90"
    assert str(opacity(95)) == "opacity-95"
    assert str(opacity(100)) == "opacity-100"
    
    # Test arbitrary decimal values
    assert str(opacity("0.87")) == "opacity-[0.87]"
    assert str(opacity("0.5")) == "opacity-[0.5]"
    assert str(opacity("0.333")) == "opacity-[0.333]"
    
    # Test CSS custom properties
    assert str(opacity("--custom-opacity")) == "opacity-(--custom-opacity)"
    assert str(opacity("--fade-amount")) == "opacity-(--fade-amount)"

# Run the tests
test_effects_opacity_examples()

Mix Blend Mode

Utilities for controlling how an element should blend with the background.


test_effects_mix_blend_examples


def test_effects_mix_blend_examples(
    
):

Test mix blend mode utilities.

Exported source
mix_blend = SimpleFactory(
    {
        "normal": "mix-blend-normal",
        "multiply": "mix-blend-multiply",
        "screen": "mix-blend-screen",
        "overlay": "mix-blend-overlay",
        "darken": "mix-blend-darken",
        "lighten": "mix-blend-lighten",
        "color_dodge": "mix-blend-color-dodge",
        "color_burn": "mix-blend-color-burn",
        "hard_light": "mix-blend-hard-light",
        "soft_light": "mix-blend-soft-light",
        "difference": "mix-blend-difference",
        "exclusion": "mix-blend-exclusion",
        "hue": "mix-blend-hue",
        "saturation": "mix-blend-saturation",
        "color": "mix-blend-color",
        "luminosity": "mix-blend-luminosity",
        "plus_darker": "mix-blend-plus-darker",
        "plus_lighter": "mix-blend-plus-lighter"
    },
    "Mix blend mode utilities for controlling how elements blend with their background"
) # Mix blend mode factory
Exported source
def test_effects_mix_blend_examples():
    """Test mix blend mode utilities."""
    assert str(mix_blend.normal) == "mix-blend-normal"
    assert str(mix_blend.multiply) == "mix-blend-multiply"
    assert str(mix_blend.screen) == "mix-blend-screen"
    assert str(mix_blend.overlay) == "mix-blend-overlay"
    assert str(mix_blend.darken) == "mix-blend-darken"
    assert str(mix_blend.lighten) == "mix-blend-lighten"
    assert str(mix_blend.color_dodge) == "mix-blend-color-dodge"
    assert str(mix_blend.color_burn) == "mix-blend-color-burn"
    assert str(mix_blend.hard_light) == "mix-blend-hard-light"
    assert str(mix_blend.soft_light) == "mix-blend-soft-light"
    assert str(mix_blend.difference) == "mix-blend-difference"
    assert str(mix_blend.exclusion) == "mix-blend-exclusion"
    assert str(mix_blend.hue) == "mix-blend-hue"
    assert str(mix_blend.saturation) == "mix-blend-saturation"
    assert str(mix_blend.color) == "mix-blend-color"
    assert str(mix_blend.luminosity) == "mix-blend-luminosity"
    assert str(mix_blend.plus_darker) == "mix-blend-plus-darker"
    assert str(mix_blend.plus_lighter) == "mix-blend-plus-lighter"

# Run the tests
test_effects_mix_blend_examples()

Background Blend Mode

Utilities for controlling how an element’s background image should blend with its background color.


test_effects_bg_blend_examples


def test_effects_bg_blend_examples(
    
):

Test background blend mode utilities.

Exported source
bg_blend = SimpleFactory(
    {
        "normal": "bg-blend-normal",
        "multiply": "bg-blend-multiply",
        "screen": "bg-blend-screen",
        "overlay": "bg-blend-overlay",
        "darken": "bg-blend-darken",
        "lighten": "bg-blend-lighten",
        "color_dodge": "bg-blend-color-dodge",
        "color_burn": "bg-blend-color-burn",
        "hard_light": "bg-blend-hard-light",
        "soft_light": "bg-blend-soft-light",
        "difference": "bg-blend-difference",
        "exclusion": "bg-blend-exclusion",
        "hue": "bg-blend-hue",
        "saturation": "bg-blend-saturation",
        "color": "bg-blend-color",
        "luminosity": "bg-blend-luminosity"
    },
    "Background blend mode utilities for controlling how background images blend with background colors"
) # Background blend mode factory
Exported source
def test_effects_bg_blend_examples():
    """Test background blend mode utilities."""
    assert str(bg_blend.normal) == "bg-blend-normal"
    assert str(bg_blend.multiply) == "bg-blend-multiply"
    assert str(bg_blend.screen) == "bg-blend-screen"
    assert str(bg_blend.overlay) == "bg-blend-overlay"
    assert str(bg_blend.darken) == "bg-blend-darken"
    assert str(bg_blend.lighten) == "bg-blend-lighten"
    assert str(bg_blend.color_dodge) == "bg-blend-color-dodge"
    assert str(bg_blend.color_burn) == "bg-blend-color-burn"
    assert str(bg_blend.hard_light) == "bg-blend-hard-light"
    assert str(bg_blend.soft_light) == "bg-blend-soft-light"
    assert str(bg_blend.difference) == "bg-blend-difference"
    assert str(bg_blend.exclusion) == "bg-blend-exclusion"
    assert str(bg_blend.hue) == "bg-blend-hue"
    assert str(bg_blend.saturation) == "bg-blend-saturation"
    assert str(bg_blend.color) == "bg-blend-color"
    assert str(bg_blend.luminosity) == "bg-blend-luminosity"

# Run the tests
test_effects_bg_blend_examples()

Mask Utilities

Utilities for controlling CSS mask properties. Masks allow you to hide portions of an element by masking it with an image or gradient.

Mask Clip

Utilities for controlling the bounding box of an element’s mask:


test_effects_mask_clip_examples


def test_effects_mask_clip_examples(
    
):

Test mask clip utilities.

Exported source
mask_clip = SimpleFactory(
    {
        "border": "mask-clip-border",
        "padding": "mask-clip-padding",
        "content": "mask-clip-content",
        "fill": "mask-clip-fill",
        "stroke": "mask-clip-stroke",
        "view": "mask-clip-view",
        "no_clip": "mask-no-clip"
    },
    "Mask clip utilities for controlling the bounding box of an element's mask"
) # Mask clip factory
Exported source
def test_effects_mask_clip_examples():
    """Test mask clip utilities."""
    assert str(mask_clip.border) == "mask-clip-border"
    assert str(mask_clip.padding) == "mask-clip-padding"
    assert str(mask_clip.content) == "mask-clip-content"
    assert str(mask_clip.fill) == "mask-clip-fill"
    assert str(mask_clip.stroke) == "mask-clip-stroke"
    assert str(mask_clip.view) == "mask-clip-view"
    assert str(mask_clip.no_clip) == "mask-no-clip"

# Run the tests
test_effects_mask_clip_examples()

Mask Composite

Utilities for controlling how multiple masks are combined together:


test_effects_mask_composite_examples


def test_effects_mask_composite_examples(
    
):

Test mask composite utilities.

Exported source
mask_composite = SimpleFactory(
    {
        "add": "mask-add",
        "subtract": "mask-subtract",
        "intersect": "mask-intersect",
        "exclude": "mask-exclude"
    },
    "Mask composite utilities for controlling how multiple masks are combined"
) # Mask composite factory
Exported source
def test_effects_mask_composite_examples():
    """Test mask composite utilities."""
    assert str(mask_composite.add) == "mask-add"
    assert str(mask_composite.subtract) == "mask-subtract"
    assert str(mask_composite.intersect) == "mask-intersect"
    assert str(mask_composite.exclude) == "mask-exclude"

# Run the tests
test_effects_mask_composite_examples()

Mask Image

Utilities for controlling an element’s mask image. Masks allow you to create complex shapes and effects by using images or gradients to selectively show or hide parts of an element.

Basic Mask Image

Support for basic mask image utilities including mask-none and arbitrary values:


MaskImageUtility


def MaskImageUtility(
    value:Optional=None, # Mask image value (none, custom property, or arbitrary)
):

Utility class for mask images.


MaskImageFactory


def MaskImageFactory(
    doc:Optional=None, # Documentation
):

Factory for basic mask image utilities.

Linear Gradient Masks

Create linear gradient masks with angle support:


MaskLinearUtility


def MaskLinearUtility(
    angle:Union=None, # Angle in degrees or custom value
    negative:bool=False, # Whether to negate the angle
):

Utility class for linear gradient masks with angle support.


MaskLinearFactory


def MaskLinearFactory(
    doc:Optional=None, # Documentation
):

Factory for linear gradient mask utilities with angle support.

Exported source
mask_linear = MaskLinearFactory("Linear gradient mask utilities for creating gradient-based masks") # Create the linear gradient mask factory instance

Directional Linear Gradient Masks

Create directional linear gradient masks with from/to positioning:


MaskDirectionalUtility


def MaskDirectionalUtility(
    direction:str, # Direction (t, r, b, l, x, y)
    position:str, # Position type (from or to)
    value:Union=None, # Value (number, percentage, color, etc.)
):

Utility class for directional mask gradients with from/to support.


MaskDirectionalFactory


def MaskDirectionalFactory(
    direction:str, # Direction (t, r, b, l, x, y)
    position:str, # Position type (from or to)
    doc:Optional=None, # Documentation
):

Factory for directional mask gradient utilities.

Exported source
# Create directional mask gradient factories
mask_t_from = MaskDirectionalFactory('t', 'from') # Top direction - from
mask_t_to = MaskDirectionalFactory('t', 'to') # Top direction - to

mask_r_from = MaskDirectionalFactory('r', 'from') # Right direction - from
mask_r_to = MaskDirectionalFactory('r', 'to') # Right direction - to

mask_b_from = MaskDirectionalFactory('b', 'from') # Bottom direction - from
mask_b_to = MaskDirectionalFactory('b', 'to') # Bottom direction - to

mask_l_from = MaskDirectionalFactory('l', 'from') # Left direction - from
mask_l_to = MaskDirectionalFactory('l', 'to') # Left direction - to

mask_x_from = MaskDirectionalFactory('x', 'from') # Horizontal (x) direction - from
mask_x_to = MaskDirectionalFactory('x', 'to') # Horizontal (x) direction - to

mask_y_from = MaskDirectionalFactory('y', 'from') # Vertical (y) direction - from
mask_y_to = MaskDirectionalFactory('y', 'to') # Vertical (y) direction - to

Radial Gradient Masks

Create radial gradient masks with shape, size, and position controls:


MaskRadialUtility


def MaskRadialUtility(
    value:Optional=None, # Arbitrary radial gradient value
):

Utility class for radial gradient masks.


MaskRadialFactory


def MaskRadialFactory(
    doc:Optional=None, # Documentation
):

Factory for radial gradient mask utilities.

Exported source
# Radial gradient shape controls
mask_circle = SingleValueFactory("mask-circle", "Set radial gradient mask shape to circle")
mask_ellipse = SingleValueFactory("mask-ellipse", "Set radial gradient mask shape to ellipse")

# Radial gradient size controls
mask_radial_closest_corner = SingleValueFactory("mask-radial-closest-corner", "Size radial gradient mask to closest corner")
mask_radial_closest_side = SingleValueFactory("mask-radial-closest-side", "Size radial gradient mask to closest side")
mask_radial_farthest_corner = SingleValueFactory("mask-radial-farthest-corner", "Size radial gradient mask to farthest corner")
mask_radial_farthest_side = SingleValueFactory("mask-radial-farthest-side", "Size radial gradient mask to farthest side")

# Radial gradient position controls
mask_radial_at_top_left = SingleValueFactory("mask-radial-at-top-left", "Position radial gradient mask at top left")
mask_radial_at_top = SingleValueFactory("mask-radial-at-top", "Position radial gradient mask at top")
mask_radial_at_top_right = SingleValueFactory("mask-radial-at-top-right", "Position radial gradient mask at top right")
mask_radial_at_left = SingleValueFactory("mask-radial-at-left", "Position radial gradient mask at left")
mask_radial_at_center = SingleValueFactory("mask-radial-at-center", "Position radial gradient mask at center")
mask_radial_at_right = SingleValueFactory("mask-radial-at-right", "Position radial gradient mask at right")
mask_radial_at_bottom_left = SingleValueFactory("mask-radial-at-bottom-left", "Position radial gradient mask at bottom left")
mask_radial_at_bottom = SingleValueFactory("mask-radial-at-bottom", "Position radial gradient mask at bottom")
mask_radial_at_bottom_right = SingleValueFactory("mask-radial-at-bottom-right", "Position radial gradient mask at bottom right")

# Radial gradient from/to positioning
mask_radial_from = MaskDirectionalFactory('radial', 'from', "Radial gradient mask from position utilities")
mask_radial_to = MaskDirectionalFactory('radial', 'to', "Radial gradient mask to position utilities")

Conic Gradient Masks

Create conic gradient masks with angle support:


MaskConicUtility


def MaskConicUtility(
    angle:Union=None, # Starting angle in degrees or custom value
    negative:bool=False, # Whether to negate the angle
):

Utility class for conic gradient masks with angle support.


MaskConicFactory


def MaskConicFactory(
    doc:Optional=None, # Documentation
):

Factory for conic gradient mask utilities with angle support.

Exported source
# Create the conic gradient mask factory instance
mask_conic = MaskConicFactory("Conic gradient mask utilities for creating conical gradient-based masks")

# Conic gradient from/to positioning
mask_conic_from = MaskDirectionalFactory('conic', 'from', "Conic gradient mask from position utilities")
mask_conic_to = MaskDirectionalFactory('conic', 'to', "Conic gradient mask to position utilities")

Mask Mode

Utilities for controlling an element’s mask mode:

Exported source
mask_mode = SimpleFactory(
    {
        "alpha": "mask-alpha",
        "luminance": "mask-luminance",
        "match": "mask-match"
    },
    "Mask mode utilities for controlling how the mask is interpreted"
) # Mask mode factory

Mask Origin

Utilities for controlling how an element’s mask image is positioned relative to borders, padding, and content:

Exported source
mask_origin = SimpleFactory(
    {
        "border": "mask-origin-border",
        "padding": "mask-origin-padding",
        "content": "mask-origin-content",
        "fill": "mask-origin-fill",
        "stroke": "mask-origin-stroke",
        "view": "mask-origin-view"
    },
    "Mask origin utilities for controlling how the mask is positioned relative to borders, padding, and content"
) # Mask origin factory

Mask Position

Utilities for controlling the position of an element’s mask image:

Exported source
mask_position = SimpleFactory(
    {
        "top_left": "mask-top-left",
        "top": "mask-top",
        "top_right": "mask-top-right",
        "left": "mask-left",
        "center": "mask-center",
        "right": "mask-right",
        "bottom_left": "mask-bottom-left",
        "bottom": "mask-bottom",
        "bottom_right": "mask-bottom-right"
    },
    "Mask position utilities for controlling the position of an element's mask image"
) # Mask position factory

Mask Repeat

Utilities for controlling the repetition of an element’s mask image:

Exported source
mask_repeat = SimpleFactory(
    {
        "repeat": "mask-repeat",
        "no_repeat": "mask-no-repeat",
        "repeat_x": "mask-repeat-x",
        "repeat_y": "mask-repeat-y",
        "repeat_space": "mask-repeat-space",
        "repeat_round": "mask-repeat-round"
    },
    "Mask repeat utilities for controlling the repetition of an element's mask image"
) # Mask repeat factory

Mask Size

Utilities for controlling the size of an element’s mask image:

Exported source
mask_size = SimpleFactory(
    {
        "auto": "mask-auto",
        "cover": "mask-cover",
        "contain": "mask-contain"
    },
    "Mask size utilities for controlling the size of an element's mask image"
) # Mask size factory

Mask Type

Utilities for controlling how an SVG mask is interpreted:

Exported source
mask_type = SimpleFactory(
    {
        "alpha": "mask-type-alpha",
        "luminance": "mask-type-luminance"
    },
    "Mask type utilities for controlling how an SVG mask is interpreted"
) # Mask type factory

Test Mask Utilities

Test all mask image utilities:


test_effects_mask_basic_examples


def test_effects_mask_basic_examples(
    
):

Test basic mask image utilities.

Exported source
def test_effects_mask_basic_examples():
    """Test basic mask image utilities."""
    # Test mask-none
    assert str(mask.none) == "mask-none"
    
    # Test arbitrary mask values
    assert str(mask("url(#my-mask)")) == "mask-[url(#my-mask)]"
    assert str(mask("linear-gradient(black, transparent)")) == "mask-[linear-gradient(black, transparent)]"
    assert str(mask("radial-gradient(circle, black, transparent)")) == "mask-[radial-gradient(circle, black, transparent)]"
    
    # Test CSS custom properties
    assert str(mask("--custom-mask")) == "mask-(--custom-mask)"
    assert str(mask("--theme-mask")) == "mask-(--theme-mask)"

# Run the tests
test_effects_mask_basic_examples()

test_effects_mask_linear_examples


def test_effects_mask_linear_examples(
    
):

Test linear gradient mask utilities.

Exported source
def test_effects_mask_linear_examples():
    """Test linear gradient mask utilities."""
    # Test common angles
    assert str(mask_linear._0) == "mask-linear-0"
    assert str(mask_linear._45) == "mask-linear-45"
    assert str(mask_linear._90) == "mask-linear-90"
    assert str(mask_linear._180) == "mask-linear-180"
    
    # Test with angle parameter
    assert str(mask_linear(30)) == "mask-linear-30"
    assert str(mask_linear(60)) == "mask-linear-60"
    assert str(mask_linear(270)) == "mask-linear-270"
    
    # Test negative angles
    assert str(mask_linear(45, negative=True)) == "-mask-linear-45"
    assert str(mask_linear.neg_90) == "-mask-linear-90"
    assert str(mask_linear.neg_180) == "-mask-linear-180"
    
    # Test CSS custom properties
    assert str(mask_linear("--gradient-angle")) == "mask-linear-(--gradient-angle)"

# Run the tests
test_effects_mask_linear_examples()

test_effects_mask_directional_examples


def test_effects_mask_directional_examples(
    
):

Test directional mask gradient utilities.

Exported source
def test_effects_mask_directional_examples():
    """Test directional mask gradient utilities."""
    # Test top direction
    assert str(mask_t_from(50)) == "mask-t-from-50"
    assert str(mask_t_from("50%")) == "mask-t-from-50%"
    assert str(mask_t_from.black) == "mask-t-from-black"
    assert str(mask_t_to(100)) == "mask-t-to-100"
    assert str(mask_t_to.transparent) == "mask-t-to-transparent"
    
    # Test right direction
    assert str(mask_r_from._20) == "mask-r-from-20"
    assert str(mask_r_from._50p) == "mask-r-from-50%"
    assert str(mask_r_to.white) == "mask-r-to-white"
    
    # Test bottom direction
    assert str(mask_b_from(0)) == "mask-b-from-0"
    assert str(mask_b_to("75%")) == "mask-b-to-75%"
    
    # Test left direction
    assert str(mask_l_from(10)) == "mask-l-from-10"
    assert str(mask_l_to(90)) == "mask-l-to-90"
    
    # Test horizontal (x) direction
    assert str(mask_x_from(25)) == "mask-x-from-25"
    assert str(mask_x_to("100%")) == "mask-x-to-100%"
    
    # Test vertical (y) direction
    assert str(mask_y_from(0)) == "mask-y-from-0"
    assert str(mask_y_to(50)) == "mask-y-to-50"
    
    # Test with custom properties
    assert str(mask_t_from("--mask-start")) == "mask-t-from-(--mask-start)"
    assert str(mask_r_to("--mask-end")) == "mask-r-to-(--mask-end)"
    
    # Test with arbitrary values
    assert str(mask_b_from("10px")) == "mask-b-from-[10px]"
    assert str(mask_l_to("5rem")) == "mask-l-to-[5rem]"

# Run the tests
test_effects_mask_directional_examples()

test_effects_mask_radial_examples


def test_effects_mask_radial_examples(
    
):

Test radial gradient mask utilities.

Exported source
def test_effects_mask_radial_examples():
    """Test radial gradient mask utilities."""
    # Test basic radial gradient
    assert str(mask_radial()) == "mask-radial"
    
    # Test arbitrary radial values
    assert str(mask_radial("circle at center")) == "mask-radial-[circle at center]"
    assert str(mask_radial("ellipse at top")) == "mask-radial-[ellipse at top]"
    assert str(mask_radial("circle 50px at 25% 75%")) == "mask-radial-[circle 50px at 25% 75%]"
    
    # Test shape controls
    assert str(mask_circle) == "mask-circle"
    assert str(mask_ellipse) == "mask-ellipse"
    
    # Test size controls
    assert str(mask_radial_closest_corner) == "mask-radial-closest-corner"
    assert str(mask_radial_closest_side) == "mask-radial-closest-side"
    assert str(mask_radial_farthest_corner) == "mask-radial-farthest-corner"
    assert str(mask_radial_farthest_side) == "mask-radial-farthest-side"
    
    # Test position controls
    assert str(mask_radial_at_top_left) == "mask-radial-at-top-left"
    assert str(mask_radial_at_top) == "mask-radial-at-top"
    assert str(mask_radial_at_top_right) == "mask-radial-at-top-right"
    assert str(mask_radial_at_center) == "mask-radial-at-center"
    assert str(mask_radial_at_bottom) == "mask-radial-at-bottom"
    
    # Test radial from/to
    assert str(mask_radial_from(0)) == "mask-radial-from-0"
    assert str(mask_radial_from("25%")) == "mask-radial-from-25%"
    assert str(mask_radial_from.black) == "mask-radial-from-black"
    assert str(mask_radial_to(100)) == "mask-radial-to-100"
    assert str(mask_radial_to.transparent) == "mask-radial-to-transparent"
    
    # Test CSS custom properties
    assert str(mask_radial("--radial-mask")) == "mask-radial-(--radial-mask)"

# Run the tests
test_effects_mask_radial_examples()

test_effects_mask_conic_examples


def test_effects_mask_conic_examples(
    
):

Test conic gradient mask utilities.

Exported source
def test_effects_mask_conic_examples():
    """Test conic gradient mask utilities."""
    # Test common angles
    assert str(mask_conic._0) == "mask-conic-0"
    assert str(mask_conic._45) == "mask-conic-45"
    assert str(mask_conic._90) == "mask-conic-90"
    assert str(mask_conic._180) == "mask-conic-180"
    
    # Test with angle parameter
    assert str(mask_conic(30)) == "mask-conic-30"
    assert str(mask_conic(120)) == "mask-conic-120"
    assert str(mask_conic(270)) == "mask-conic-270"
    
    # Test negative angles
    assert str(mask_conic(45, negative=True)) == "-mask-conic-45"
    assert str(mask_conic.neg_90) == "-mask-conic-90"
    assert str(mask_conic.neg_180) == "-mask-conic-180"
    
    # Test conic from/to
    assert str(mask_conic_from(0)) == "mask-conic-from-0"
    assert str(mask_conic_from("25%")) == "mask-conic-from-25%"
    assert str(mask_conic_from.black) == "mask-conic-from-black"
    assert str(mask_conic_to(180)) == "mask-conic-to-180"
    assert str(mask_conic_to.transparent) == "mask-conic-to-transparent"
    
    # Test CSS custom properties
    assert str(mask_conic("--conic-angle")) == "mask-conic-(--conic-angle)"

# Run the tests
test_effects_mask_conic_examples()

test_effects_mask_properties_examples


def test_effects_mask_properties_examples(
    
):

Test mask property utilities (mode, origin, position, etc.).

Exported source
def test_effects_mask_properties_examples():
    """Test mask property utilities (mode, origin, position, etc.)."""
    # Test mask mode
    assert str(mask_mode.alpha) == "mask-alpha"
    assert str(mask_mode.luminance) == "mask-luminance"
    assert str(mask_mode.match) == "mask-match"
    
    # Test mask origin
    assert str(mask_origin.border) == "mask-origin-border"
    assert str(mask_origin.padding) == "mask-origin-padding"
    assert str(mask_origin.content) == "mask-origin-content"
    assert str(mask_origin.fill) == "mask-origin-fill"
    assert str(mask_origin.stroke) == "mask-origin-stroke"
    assert str(mask_origin.view) == "mask-origin-view"
    
    # Test mask position
    assert str(mask_position.top_left) == "mask-top-left"
    assert str(mask_position.top) == "mask-top"
    assert str(mask_position.center) == "mask-center"
    assert str(mask_position.bottom_right) == "mask-bottom-right"
    
    # Test mask repeat
    assert str(mask_repeat.repeat) == "mask-repeat"
    assert str(mask_repeat.no_repeat) == "mask-no-repeat"
    assert str(mask_repeat.repeat_x) == "mask-repeat-x"
    assert str(mask_repeat.repeat_y) == "mask-repeat-y"
    assert str(mask_repeat.repeat_space) == "mask-repeat-space"
    assert str(mask_repeat.repeat_round) == "mask-repeat-round"
    
    # Test mask size
    assert str(mask_size.auto) == "mask-auto"
    assert str(mask_size.cover) == "mask-cover"
    assert str(mask_size.contain) == "mask-contain"
    
    # Test mask type
    assert str(mask_type.alpha) == "mask-type-alpha"
    assert str(mask_type.luminance) == "mask-type-luminance"

# Run the tests
test_effects_mask_properties_examples()

Practical Examples

Let’s see how to use shadow utilities in real FastHTML components:


test_effects_shadow_fasthtml_examples


def test_effects_shadow_fasthtml_examples(
    
):

Test shadow utilities in practical FastHTML component examples.

Exported source
def test_effects_shadow_fasthtml_examples():
    """Test shadow utilities in practical FastHTML component examples."""
    from fasthtml.common import Div, H2, P, Button
    from cjm_fasthtml_tailwind.utilities.spacing import p
    from cjm_fasthtml_tailwind.utilities.backgrounds import bg
    from cjm_fasthtml_tailwind.utilities.borders import rounded, border, border_color
    from cjm_fasthtml_tailwind.utilities.transitions_and_animation import transition
    from cjm_fasthtml_tailwind.utilities.typography import font_size, text_color
    from cjm_fasthtml_tailwind.utilities.sizing import w, h
    from cjm_fasthtml_tailwind.utilities.flexbox_and_grid import gap, grid_display
    from cjm_fasthtml_tailwind.utilities.layout import display_tw
    
    # Card with basic shadow
    card = Div(
        H2("Card Title"),
        P("Card content goes here."),
        cls=combine_classes(shadow.md, p(6), bg.white, rounded.lg)
    )
    assert "shadow-md" in card.attrs['class']
    
    # Button with hover shadow effect
    button = Button(
        "Click me",
        cls=combine_classes(
            shadow.sm,
            shadow.lg.hover,
            transition.shadow,
            p.x(4), p.y(2), bg.blue._500, text_color.white, rounded.full
        )
    )
    assert "shadow-sm" in button.attrs['class']
    
    # Card with colored shadow
    colored_card = Div(
        "Content with colored shadow",
        cls=combine_classes(
            shadow.xl,
            shadow_color.blue._500,
            p(8), bg.white, rounded.xl
        )
    )
    assert "shadow-xl" in colored_card.attrs['class']
    assert "shadow-blue-500" in colored_card.attrs['class']
    
    # Floating action button with large shadow
    fab = Button(
        "+",
        cls=combine_classes(
            shadow._2xl,
            shadow_color.black,
            w(14), h(14), rounded.full, bg.purple._600, text_color.white
        )
    )
    assert "shadow-2xl" in fab.attrs['class']
    assert "shadow-black" in fab.attrs['class']
    
    # Card with no shadow (flat design)
    flat_card = Div(
        "Flat design card",
        cls=combine_classes(
            shadow.none,
            p(4), bg.gray._100, border(), border_color.gray._300
        )
    )
    assert "shadow-none" in flat_card.attrs['class']
    
    # Card with custom shadow
    custom_shadow_card = Div(
        "Custom shadow",
        cls=combine_classes(
            shadow("0 10px 30px -10px rgba(0, 0, 0, 0.3)"),
            p(6), bg.white, rounded.full
        )
    )
    assert "shadow-[0 10px 30px -10px rgba(0, 0, 0, 0.3)]" in custom_shadow_card.attrs['class']
    
    # Input with inset shadow for depth
    input_field = Div(
        cls=combine_classes(
            inset_shadow.sm,
            inset_shadow_color.gray._400,
            p(3), bg.gray._50, rounded.full, border(), border_color.gray._300
        )
    )
    assert "inset-shadow-sm" in input_field.attrs['class']
    assert "inset-shadow-gray-400" in input_field.attrs['class']
    
    # Button with focus ring
    focus_button = Button(
        "Focus me",
        cls=combine_classes(
            ring(2).focus,
            ring_color.blue._500.focus,
            p.x(4), p.y(2), bg.gray._200, rounded.full
        )
    )
    assert "focus:ring-2" in focus_button.attrs['class']
    
    # Card with custom ring
    ring_card = Div(
        "Ring example",
        cls=combine_classes(
            ring(2),
            ring_color.purple._500,
            p(6), bg.white, rounded.full
        )
    )
    assert "ring-2" in ring_card.attrs['class']
    assert "ring-purple-500" in ring_card.attrs['class']
    
    # Return all examples in a grid layout
    return Div(
        card,
        button,
        colored_card,
        fab,
        flat_card,
        custom_shadow_card,
        input_field,
        focus_button,
        ring_card,
        cls=combine_classes(grid_display, gap(5))
    )

# Run the tests
test_effects_shadow_fasthtml_examples()

Card Title

Card content goes here.

Content with colored shadow
Flat design card
Custom shadow
Ring example
test_func = test_effects_shadow_fasthtml_examples
app, rt = create_test_app()

@rt
def index():
    return create_test_page(test_func.__doc__.title().replace('.', ''), test_func())
server = start_test_server(app)
display(HTMX())
server.stop()

test_effects_shadow_composition_fasthtml_examples


def test_effects_shadow_composition_fasthtml_examples(
    
):

Test composing shadow size and color utilities.

Exported source
def test_effects_shadow_composition_fasthtml_examples():
    """Test composing shadow size and color utilities."""
    from fasthtml.common import Div
    from cjm_fasthtml_tailwind.utilities.layout import display_tw
    from cjm_fasthtml_tailwind.utilities.flexbox_and_grid import gap, grid_display
    
    # Small shadow with custom color
    example1 = Div(
        "Small blue shadow",
        cls=combine_classes(
            shadow.sm,
            shadow_color.blue._400,
            "p-4 bg-white"
        )
    )
    assert "shadow-sm" in example1.attrs['class']
    assert "shadow-blue-400" in example1.attrs['class']
    
    # Large shadow with red color
    example2 = Div(
        "Large red shadow",
        cls=combine_classes(
            shadow.xl,
            shadow_color.red._600,
            "p-6 bg-white"
        )
    )
    assert "shadow-xl" in example2.attrs['class']
    assert "shadow-red-600" in example2.attrs['class']
    
    # Extra small shadow with transparent color
    example3 = Div(
        "Subtle transparent shadow",
        cls=combine_classes(
            shadow._2xs,
            shadow_color.transparent,
            "p-3 bg-gray-50"
        )
    )
    assert "shadow-2xs" in example3.attrs['class']
    assert "shadow-transparent" in example3.attrs['class']
    
    # Medium shadow with custom hex color
    example4 = Div(
        "Custom color shadow",
        cls=combine_classes(
            shadow.md,
            shadow_color("#6B46C1"),  # Purple hex
            "p-5 bg-white"
        )
    )
    assert "shadow-md" in example4.attrs['class']
    assert "shadow-[#6B46C1]" in example4.attrs['class']

    return Div(
        example1,
        example2,
        example3,
        example4,
        cls=combine_classes(grid_display, gap(5))
    )

# Run the tests
test_effects_shadow_composition_fasthtml_examples()
Small blue shadow
Large red shadow
Subtle transparent shadow
Custom color shadow
test_func = test_effects_shadow_composition_fasthtml_examples
app, rt = create_test_app()

@rt
def index():
    return create_test_page(test_func.__doc__.title().replace('.', ''), test_func())
server = start_test_server(app)
display(HTMX())
server.stop()

test_effects_comprehensive_fasthtml_examples


def test_effects_comprehensive_fasthtml_examples(
    
):

Test comprehensive usage of all effect utilities.

Exported source
def test_effects_comprehensive_fasthtml_examples():
    """Test comprehensive usage of all effect utilities."""
    from fasthtml.common import Div, Input, Button
    from cjm_fasthtml_tailwind.utilities.spacing import p
    from cjm_fasthtml_tailwind.utilities.backgrounds import bg, bg_linear, from_color, to_color
    from cjm_fasthtml_tailwind.utilities.borders import rounded, border, border_color
    from cjm_fasthtml_tailwind.utilities.typography import font_size, text_color
    from cjm_fasthtml_tailwind.utilities.layout import display_tw
    from cjm_fasthtml_tailwind.utilities.flexbox_and_grid import gap, grid_display
    
    # Form input with inset shadow
    form_input = Input(
        type="text",
        placeholder="Enter text",
        cls=combine_classes(
            inset_shadow.xs,
            inset_shadow_color.gray._300,
            p.x(4), p.y(2), bg.white, border(), border_color.gray._200, rounded.md,
            inset_shadow.sm.focus,
            inset_shadow_color.blue._400.focus
        )
    )
    assert "inset-shadow-xs" in form_input.attrs['class']
    assert "inset-shadow-gray-300" in form_input.attrs['class']
    
    # Button with ring on focus
    ring_button = Button(
        "Click for Ring",
        cls=combine_classes(
            p.x(6), p.y(3), bg.blue._500, text_color.white, rounded.lg,
            ring(4).focus,
            ring_color.blue._300.focus
        )
    )
    assert "focus:ring-4" in ring_button.attrs['class']
    
    # Card with inset ring
    inset_ring_card = Div(
        "Inset Ring Card",
        cls=combine_classes(
            inset_ring(2),
            inset_ring_color.indigo._400,
            p(8), bg.white, rounded.xl
        )
    )
    assert "inset-ring-2" in inset_ring_card.attrs['class']
    assert "inset-ring-indigo-400" in inset_ring_card.attrs['class']
    
    # Complex shadow layering
    layered_card = Div(
        "Layered Effects",
        cls=combine_classes(
            shadow.lg,
            shadow_color.purple._500,
            inset_shadow.sm,
            inset_shadow_color.purple._200,
            p(6), bg_linear.to_br, from_color.purple._100, to_color.purple._50, rounded.lg
        )
    )
    assert "shadow-lg" in layered_card.attrs['class']
    assert "shadow-purple-500" in layered_card.attrs['class']
    assert "inset-shadow-sm" in layered_card.attrs['class']
    assert "inset-shadow-purple-200" in layered_card.attrs['class']
    
    # Remove all effects
    no_effects = Div(
        "No Effects",
        cls=combine_classes(
            shadow.none,
            inset_shadow.none,
            ring(0),
            inset_ring(0),
            p(4), bg.gray._100
        )
    )
    assert "shadow-none" in no_effects.attrs['class']
    assert "inset-shadow-none" in no_effects.attrs['class']
    assert "ring-0" in no_effects.attrs['class']
    assert "inset-ring-0" in no_effects.attrs['class']

    return Div(
        form_input,
        ring_button,
        inset_ring_card,
        layered_card,
        no_effects,
        cls=combine_classes(grid_display, gap(5))
    )

# Run the tests
test_effects_comprehensive_fasthtml_examples()
Inset Ring Card
Layered Effects
No Effects
test_func = test_effects_comprehensive_fasthtml_examples
app, rt = create_test_app()

@rt
def index():
    return create_test_page(test_func.__doc__.title().replace('.', ''), test_func())
server = start_test_server(app)
display(HTMX())
server.stop()

Practical Mask Examples

Let’s see how to use mask utilities in real FastHTML components:


test_effects_mask_fasthtml_examples


def test_effects_mask_fasthtml_examples(
    
):

Test mask utilities in practical FastHTML component examples.

Exported source
def test_effects_mask_fasthtml_examples():
    """Test mask utilities in practical FastHTML component examples."""
    from fasthtml.common import Div, Img, Section, H1, P
    from cjm_fasthtml_tailwind.utilities.spacing import p
    from cjm_fasthtml_tailwind.utilities.backgrounds import bg, bg_linear, from_color, to_color, via_color
    from cjm_fasthtml_tailwind.utilities.typography import font_size, text_color
    from cjm_fasthtml_tailwind.utilities.layout import position, overflow, display_tw
    from cjm_fasthtml_tailwind.utilities.sizing import w, h
    from cjm_fasthtml_tailwind.utilities.borders import rounded
    from cjm_fasthtml_tailwind.utilities.flexbox_and_grid import gap, grid_display
    
    # Fade out effect with linear gradient mask
    fade_out_div = Div(
        P("This text fades out at the bottom"),
        cls=combine_classes(
            mask_linear._180,
            mask_t_from.black,
            mask_t_to.transparent,
            p(8), bg.blue._500, text_color.white
        )
    )
    assert "mask-linear-180" in fade_out_div.attrs['class']
    assert "mask-t-from-black" in fade_out_div.attrs['class']
    assert "mask-t-to-transparent" in fade_out_div.attrs['class']
    
    # Circular reveal with radial gradient mask
    circular_reveal = Div(
        Img(src="https://img.daisyui.com/images/stock/photo-1559703248-dcaaec9fab78.webp"),
        cls=combine_classes(
            mask_radial(),
            mask_circle,
            mask_radial_at_center,
            mask_radial_from.black,
            mask_radial_to.transparent,
            position.relative, overflow.hidden
        )
    )
    assert "mask-radial" in circular_reveal.attrs['class']
    assert "mask-circle" in circular_reveal.attrs['class']
    assert "mask-radial-at-center" in circular_reveal.attrs['class']
    
    # Horizontal fade edges effect
    fade_edges = Div(
        "Content with faded edges",
        cls=combine_classes(
            mask_x_from._10,
            mask_x_to._90,
            p.x(8), p.y(4), bg_linear.to_r, from_color.purple._500, to_color.pink._500, text_color.white
        )
    )
    assert "mask-x-from-10" in fade_edges.attrs['class']
    assert "mask-x-to-90" in fade_edges.attrs['class']
    
    # Corner spotlight effect with radial mask
    corner_spotlight = Section(
        H1("Spotlight Effect"),
        cls=combine_classes(
            mask_radial(),
            mask_ellipse,
            mask_radial_at_top_left,
            mask_radial_farthest_corner,
            mask_radial_from.black,
            mask_radial_to.transparent,
            p(16), bg.gray._900, text_color.white
        )
    )
    assert "mask-ellipse" in corner_spotlight.attrs['class']
    assert "mask-radial-at-top-left" in corner_spotlight.attrs['class']
    assert "mask-radial-farthest-corner" in corner_spotlight.attrs['class']
    
    # SVG mask reference
    svg_masked = Div(
        "Content with SVG mask",
        cls=combine_classes(
            mask("url(#star-mask)"),
            mask_size.cover,
            mask_position.center,
            mask_repeat.no_repeat,
            p(8), bg_linear.to_br, from_color.yellow._400, to_color.orange._500
        )
    )
    assert "mask-[url(#star-mask)]" in svg_masked.attrs['class']
    assert "mask-cover" in svg_masked.attrs['class']
    assert "mask-center" in svg_masked.attrs['class']
    assert "mask-no-repeat" in svg_masked.attrs['class']
    
    # Conic gradient pie chart mask
    pie_mask = Div(
        "Pie chart effect",
        cls=combine_classes(
            mask_conic._0,
            mask_conic_from.black,
            mask_conic_to.transparent,
            w(32), h(32), bg.blue._600, rounded.full
        )
    )
    assert "mask-conic-0" in pie_mask.attrs['class']
    assert "mask-conic-from-black" in pie_mask.attrs['class']
    
    # Complex gradient mask composition
    complex_mask = Div(
        "Complex masked content",
        cls=combine_classes(
            mask_linear._45,
            mask_t_from._20,
            mask_b_from._20,
            mask_l_from("10%"),
            mask_r_to("90%"),
            mask_mode.alpha,
            mask_origin.content,
            p(12), bg_linear.to_r, from_color.indigo._500, via_color.purple._500, to_color.pink._500, text_color.white
        )
    )
    assert "mask-linear-45" in complex_mask.attrs['class']
    assert "mask-t-from-20" in complex_mask.attrs['class']
    assert "mask-alpha" in complex_mask.attrs['class']
    assert "mask-origin-content" in complex_mask.attrs['class']
    
    # Return all examples in a grid layout
    return Div(
        fade_out_div,
        circular_reveal,
        fade_edges,
        corner_spotlight,
        svg_masked,
        pie_mask,
        complex_mask,
        cls=combine_classes(grid_display, gap(5))
    )

# Run the tests
test_effects_mask_fasthtml_examples()

This text fades out at the bottom

Content with faded edges

Spotlight Effect

Content with SVG mask
Pie chart effect
Complex masked content
test_func = test_effects_mask_fasthtml_examples
app, rt = create_test_app()

@rt
def index():
    return create_test_page(test_func.__doc__.title().replace('.', ''), test_func())
server = start_test_server(app)
display(HTMX())
server.stop()

Export