> ## Content Index
> Fetch the complete content index at: https://brilaro.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Collapsible Sections in the Power Apps HTML Text Control (No JavaScript)
- URL: https://brilaro.com/collapsible-sections-in-the-power-apps-html-text-control-no-javascript/
- Published: 2026-10-08T05:54:51.000Z
- Updated: 2026-10-08T06:02:05.000Z
- Author: Neal
- Tags: Power Apps: Canvas

he HTML text control can't run JavaScript, but it doesn't need to. The native `<details>` and `<summary>` elements give you expand-and-collapse sections, and the browser handles the toggling itself. Build the markup in a formula and the whole thing stays no-code.

This post shows the basic pattern with a live preview you can switch to the code, how to use it in a formula, and how to style it with inline CSS only.

## How it works

A `<details>` element wraps a collapsible section. Its first child, `<summary>`, is the clickable heading. Everything after the summary shows and hides when the heading is clicked:

```html
<details>
  <summary>Requirements</summary>
  <p>This text is hidden until the heading is clicked.</p>
</details>
```

Add the `open` attribute to start a section expanded. There are no click handlers, no variables, and no timers, so nothing in Power Fx needs to track which sections are open.

Write every style inline with `style=''` attributes, as the examples below do.

## See it work

Click the headings below, then switch to the **Code** tab to copy the HTML.

Preview Code 

Power Apps HtmlText control 

Click a section to expand or collapse it.

● Overview 

Collapsible sections keep a long record readable. People see the headings first and open only the parts they need, so a screen full of detail stays short and easy to scan.

● Requirements 

A Power Apps license, access to the SharePoint site, and edit permission on the list that holds the records.

● Support 

Reach the team in the support channel during business hours. For urgent issues, include the record ID and a screenshot so the problem can be reproduced quickly.

● Notes 

Nothing to add yet. Bound to data, an empty field can show N/A instead of leaving a blank section.

Power Fx · paste into the HtmlText property

```
With(
    {
        card: "background-color:rgba(128,128,128,0.09);border-radius:10px;padding:12px 16px;",
        sum: "cursor:pointer;font-size:11px;font-weight:700;letter-spacing:1px;text-transform:uppercase;",
        txt: "display:block;font-size:13px;line-height:1.55;white-space:pre-wrap;word-break:break-word;padding-top:8px;",
        cA: "#20B2AA",
        cB: "#FFA51F",
        cC: "#2D4F68",
        cD: "#8A94A6"
    },
    $"
    <details style='{card}border-left:4px solid {cA};margin:8px 0;' open>
        <summary style='{sum}'><span style='color:{cA};font-size:14px;'>●</span> Overview</summary>
        <span style='{txt}'>Collapsible sections keep a long record readable. People see the headings first and open only the parts they need, so a screen full of detail stays short and easy to scan.</span>
    </details>
    <details style='{card}border-left:4px solid {cB};margin:8px 0;'>
        <summary style='{sum}'><span style='color:{cB};font-size:14px;'>●</span> Requirements</summary>
        <span style='{txt}'>A Power Apps license, access to the SharePoint site, and edit permission on the list that holds the records.</span>
    </details>
    <details style='{card}border-left:4px solid {cC};margin:8px 0;'>
        <summary style='{sum}'><span style='color:{cC};font-size:14px;'>●</span> Support</summary>
        <span style='{txt}'>Reach the team in the support channel during business hours. For urgent issues, include the record ID and a screenshot so the problem can be reproduced quickly.</span>
    </details>
    <details style='{card}border-left:4px solid {cD};margin:8px 0;'>
        <summary style='{sum}'><span style='color:{cD};font-size:14px;'>●</span> Notes</summary>
        <span style='{txt}'>Nothing to add yet. Bound to data, an empty field can show N/A instead of leaving a blank section.</span>
    </details>
    "
)
```

## Use it in Power Apps

Copy the formula from the Code tab into the HtmlText control's `HtmlText` property. The text is typed straight into the formula, so it works anywhere with no data source. Here is what each part does:

- **`With` holds the styles once.** `card`, `sum` and `txt` carry the shared CSS, and `cA` to `cD` hold one color per section, so changing the look is a one-line edit.
- **`$"..."` interpolates.** Anything in `{}` is evaluated, so `{card}` drops the shared style into each section.
- **The text sits in a `<span>` with `display:block`.** `white-space:pre-wrap` keeps line breaks, and `word-break:break-word` stops long values running off the card.
- **The translucent background** `rgba(128,128,128,0.09)` reads on both light and dark themes, with no theme token needed.
- **Single quotes inside the HTML.** The string is wrapped in double quotes, so single-quoted attributes need no escaping.
- **`open` is optional.** Leave it off and every section starts collapsed. Add it to the ones you want expanded.

## Bind it to a form or gallery

To fill the sections from data, replace the typed text with a field. Inside a gallery template or a form data card, `ThisItem` is the current record:

```
<span style='{txt}'>{Coalesce(ThisItem.Overview,"N/A")}</span>
```

Do this for each section and use that section's own column, such as `ThisItem.Requirements`, `ThisItem.Support` and `ThisItem.Notes`. Each record then gets its own set of collapsible sections.

`Coalesce(..., "N/A")` shows N/A when the field is empty, so a section is never blank. On a screen with no gallery or form, point at a record instead, for example `Gallery1.Selected.Overview`.

**Tip:** with more than a few sections, keep them in a collection with `Title` and `Body` columns and build the markup with `Concat`, so adding a section is one new row instead of another block of HTML:

```
Concat(
    colSections,
    "<details style='...'><summary style='...'>" & Title & "</summary><div style='...'>" & Body & "</div></details>"
)
```

## Add an icon to the heading

The browser draws a small triangle beside each summary. To use your own icon instead, hide the default marker with `list-style:none` on the summary and put an SVG at the start of the heading. The [SVG icons post](https://brilaro.com/use-svg-icons-in-power-apps-canvas-apps/) shows how to build the `data:image/svg+xml` source from an `_AppAssets` list.

## Common mistakes

- **Sections won't open:** the tag or attribute was stripped. Keep to `details`, `summary`, `span` and inline styles, and test with the plain three-line example first.
- **Styles are ignored:** they were written in a `<style>` block. Move them to `style=''` attributes.
- **Line breaks disappear or long text overflows:** add `white-space:pre-wrap;word-break:break-word;` to the text span.
- **A section is blank when bound to data:** the field is empty. Wrap it in `Coalesce(..., "N/A")`.
- **The formula won't parse:** a double quote slipped into the HTML. Use single quotes for every attribute.

## Recap

1. Wrap each section in `<details>` with a `<summary>` heading. The browser does the toggling.
2. Keep the shared styles and colors in a `With` block, and build the markup with `$"..."` interpolation.
3. Style with inline CSS only, and use single quotes inside the Power Fx string.
4. To use it in a form or gallery, swap the typed text for `Coalesce(ThisItem.Field, "N/A")`.
5. For many sections, keep them in a collection and build the markup with `Concat`.