Sub topic 6
Button states: default, hover, pressed, disabled
This chapter assumes you can insert a button in Power BI Desktop, assign an action to it, and open the Format pane. It also assumes you know what a bookmark is and have used the Selection pane. Here you will learn how a button changes its appearance by state, how to set each state, and how to avoid the errors that make buttons look broken or confusing.
What a button state is
A button state is a set of formatting options that Power BI applies to a button depending on what the user is doing with it. Each state has its own style settings, so you can make a button look different when the pointer is over it or when it is clicked.
Power BI buttons have four states:
| State | When Power BI applies it |
|---|---|
| Default | The button is idle. No pointer is over it. |
| On hover | The pointer is over the button. |
| On press | The user is pressing the button (mouse down or touch). |
| Disabled | The button's action cannot run, or the button is turned off. |
The default state is the baseline. The other states start from their own settings and only look different if you change them. A state you leave untouched can look identical to the default, which gives the user no feedback.
Where to set states
Select the button, open the Format pane, and find the Style section. A State drop-down at the top of that section lets you pick Default, On hover, On press, or Disabled. Whatever you change in the Style cards (Text, Icon, Outline, Fill, Shadow, and Glow) applies only to the state you picked.
Follow this order:
- Finish the Default state first. Set text, fill, outline, and icon.
- Switch the State drop-down to On hover and change one or two properties, such as a darker fill.
- Switch to On press and make a stronger change than hover, such as a darker fill plus a thicker outline.
- Switch to Disabled and use a muted fill and text color.
How state feedback relates to the action
A state is formatting only. It does not decide what the button does. The action (Bookmark, Page navigation, Back, Apply all slicers, Clear all slicers) is set separately in the Action section. The two interact in a few ways.
- Hover and press show up in Power BI Desktop only with Ctrl+click. In Desktop, clicking a button while editing selects it. Users in Reading view or the Power BI service click normally, so test hover and press there.
- Disabled appears when an action has no valid target. For example, a Back button on the first page has nothing to go back to. A page navigation button whose destination page is hidden from the user, or is missing, may also appear disabled. Check the Disabled state formatting so these buttons look intentional rather than broken.
- Hover feedback needs an action to feel honest. If you give a decorative button (an action type of None) a hover effect, users will expect it to do something.
Worked example: a selected-view button
A common design need is a button that shows it is the current choice. Suppose you have two buttons, Chart and Table, that switch views with bookmarks. The bookmark action does not mark the active button. You have to do it yourself.
A simple approach uses a pair of bookmarks per view and two copies of each button:
- Create buttons Chart (active) and Chart (inactive). Format the active one with a strong fill and the inactive one with a light fill.
- Do the same for Table.
- In the Selection pane, show only the active chart button and inactive table button in the Chart view. Reverse this in the Table view.
- Capture a bookmark for each view with the Display option on.
- Assign each inactive button the bookmark for its own view. Leave the active button with an action of None, or point it at the same bookmark.
The inactive buttons use the Default state to look available and the On hover state to invite a click. The active buttons need no hover effect, because clicking them changes nothing.
This approach uses visibility to represent state, so it relies on bookmarks capturing the Display option. Chapter material on capture options covers why that matters.
Using the Disabled state on purpose
Disabled formatting is useful for a button that should not be available in some conditions. Two situations come up often.
An action that has no valid target. Power BI sets the button to the Disabled state automatically. Power BI does not do this for a bookmark button whose bookmark is deleted, so check for such buttons when you clean up a report.
A conditional action. With dynamic action settings (covered in a later chapter on dynamic buttons), a measure can return a page name or nothing. When the value is blank or invalid, the button has no destination and shows its Disabled style.
Make the Disabled style clearly weaker than Default: lower contrast text, a flatter fill, and no shadow. Keep the text legible, though. Disabled controls are exempt from some contrast rules in accessibility standards, but users still need to read what the button would do.
Common errors
- Styling the wrong state. You set a hover color, but the State drop-down was still on Default, so every state looks the same. Always check which state is selected before you edit.
- Hover and press that look the same. If users cannot tell hover from press, they cannot tell whether a click registered. Make press visibly stronger.
- Tooltip and alternative text missing. State changes do not help screen reader users. Set Alt text in the General section, and use a tooltip to describe the action.
- Icon-only buttons with no state change. Icons often keep the same color across states. Update the Icon card color for hover and press too.
- Expecting state to persist. Pressed is a momentary state. It ends when the user releases the mouse. It does not record that a button is selected. For a persistent "selected" look, use the visibility technique shown above, or a dynamic approach with conditional formatting.
- Copy and paste drift. When you copy a button, its state formatting travels with it. If you then change the Default fill on the copy, the hover and press fills do not update. Re-check all states after you restyle copies.
Testing states
Test in a way that matches how users will meet the report:
- Switch to Reading view in Desktop, or publish and open the report in the service.
- Move the pointer slowly over each button and confirm the hover change.
- Press and hold the mouse button on each one and confirm the press change.
- Walk each page to the first and last positions to check the Back button and navigation buttons for disabled behavior.
- Tab through the report with the keyboard. Focus outlines are separate from the hover state, so confirm that every button shows a visible focus indicator and that tab order is sensible.
On touch devices there is no hover. A button there goes straight from Default to On press, so make sure the Default state alone communicates that the item is clickable.
Exercise
You built a Chart/Table switch with two buttons. After a user clicks Table, both buttons look identical, so users cannot tell which view is active. A colleague suggests setting a dark On press fill on the Table button. Why does this not solve the problem, and what would?
Show answer
On press is a momentary state. It only applies while the mouse button is held down, so the dark fill disappears as soon as the user releases it and does not mark the selected view. Instead, use two copies of each button (active and inactive styling), control their visibility in the Selection pane per view, and capture each view in a bookmark with the Display option so the correct copies show after the bookmark is applied. Add a second cue besides color, such as an outline or bold text.
Exercise
You styled the On hover fill for a button, but when you test it, the button looks the same on hover as it does at rest. Name two likely causes.
Show answer
First, the State drop-down may have been set to Default while you edited, so the hover settings were never changed. Second, you may be testing in Desktop edit mode, where clicking selects the button rather than behaving as a reader would. Test in Reading view or the Power BI service. A third possibility is that the hover fill is the same as the Default fill.