Title: WithFallbackStyles
Published: March 9, 2021
Last modified: October 14, 2026

---

# WithFallbackStyles

## Usage

    ```language-jsx
    import { withFallbackStyles, Button } from '@wordpress/components';

    const { getComputedStyle } = window;

    const MyComponentWithFallbackStyles = withFallbackStyles(
        ( node, ownProps ) => {
            const buttonNode = node.querySelector( 'button' );
            return {
                fallbackBackgroundColor: getComputedStyle( buttonNode )
                    .backgroundColor,
                fallbackTextColor: getComputedStyle( buttonNode ).color,
            };
        }
    )( ( { fallbackTextColor, fallbackBackgroundColor } ) => (
        <div>
            <Button variant="primary">My button</Button>
            <div>Text color: { fallbackTextColor }</div>
            <div>Background color: { fallbackBackgroundColor }</div>
        </div>
    ) );
    ```

First published

March 9, 2021

Last updated

October 14, 2026

Edit article

[ Improve it on GitHub: WithFallbackStyles ](https://github.com/WordPress/gutenberg/edit/trunk/packages/components/src/higher-order/with-fallback-styles/README.md)

[  Previous: WithConstrainedTabbing](https://developer.wordpress.org/block-editor/reference-guides/components/with-constrained-tabbing/)

[  Next: WithFilters](https://developer.wordpress.org/block-editor/reference-guides/components/with-filters/)