> For the complete documentation index, see [llms.txt](https://docs.realmacsoftware.com/elements-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.realmacsoftware.com/elements-docs/elements-language/component/hooks.js/available-data/rw.theme.md).

# rw\.theme

The `rw.theme` object provides access to theme configuration, including responsive breakpoints.

## Properties

| Property              | Type   | Description                                                |
| --------------------- | ------ | ---------------------------------------------------------- |
| `breakpoints.names`   | Array  | Breakpoint names (e.g., `["sm", "md", "lg", "xl", "2xl"]`) |
| `breakpoints.screens` | Object | Breakpoint widths in pixels                                |

## Accessing Theme Data

```javascript
const transformHook = (rw) => {
    const { breakpoints } = rw.theme;
    const { names, screens } = breakpoints;

    console.log(names);   // ["sm", "md", "lg", "xl", "2xl"]
    console.log(screens); // { sm: 640, md: 768, lg: 1024, xl: 1280, "2xl": 1536 }
};

exports.transformHook = transformHook;
```

## Responsive Image Sources

A common use case is generating responsive image sources based on breakpoints:

```javascript
const transformHook = (rw) => {
    const { breakpoints } = rw.theme;
    const { names, screens } = breakpoints;
    const { image } = rw.props;

    // Generate responsive sources sorted by screen size (largest first)
    const sources = names
        .filter(name => screens[name])
        .sort((a, b) => screens[b] - screens[a])
        .map(name => ({
            media: `(min-width: ${screens[name]}px)`,
            srcset: rw.resizeResource(image, screens[name] * 2),
            breakpoint: name,
            minWidth: screens[name]
        }));

    rw.setProps({
        sources,
        fallbackSrc: image.image
    });
};

exports.transformHook = transformHook;
```

## Using Breakpoints for Conditional Logic

```javascript
const transformHook = (rw) => {
    const { breakpoints } = rw.theme;
    const { responsiveSettings } = rw.responsiveProps;

    // Access responsive property values at each breakpoint
    const { names } = breakpoints;

    names.forEach(breakpoint => {
        if (responsiveSettings[breakpoint]) {
            console.log(`Setting at ${breakpoint}:`, responsiveSettings[breakpoint]);
        }
    });
};

exports.transformHook = transformHook;
```

## Building Media Query Classes

```javascript
const transformHook = (rw) => {
    const { breakpoints } = rw.theme;
    const { hideOnMobile, hideOnDesktop } = rw.props;

    const visibilityClasses = [];

    if (hideOnMobile) {
        visibilityClasses.push('hidden', 'md:block');
    }

    if (hideOnDesktop) {
        visibilityClasses.push('block', 'lg:hidden');
    }

    rw.setProps({
        visibilityClasses: visibilityClasses.join(' ')
    });
};

exports.transformHook = transformHook;
```

## Using in Templates

```html
<!-- Generate picture element with responsive sources -->
<picture>
    @each(source in sources)
        <source media="{{source.media}}" srcset="{{source.srcset}}">
    @endeach
    <img src="{{fallbackSrc}}" alt="{{alt}}">
</picture>
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.realmacsoftware.com/elements-docs/elements-language/component/hooks.js/available-data/rw.theme.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
