# The shape of a button

**URL:** https://discourse.nodered.org/t/the-shape-of-a-button/90853
**Category:** Dashboard
**Tags:** dashboard-2
**Created:** [10 September 2024 14:03 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853 "2024-09-10T14:03:38Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [10 September 2024 14:03 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/1 "2024-09-10T14:03:38Z")

</div>

Here are a few buttons, 3 with default styling and 3 with border-radius: 50% and colour changes.  
The button label shows what size it is - 1x1, 2x1 or 2x4.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/d/8d36db4268b85e7baf8510695dd0a40cfa425358.png)

1. Perhaps foolishly, I expected a 1x1 or 2x2 button to be square, but it's rectangular. Why? Is there a way to configure the template so they will become square?
2. If I try to make a button square by specifying 2 wide and 4 tall, it becomes _almost_ square. Just sufficiently not square so that it looks wrong. On my browser, full screen it seems to be 283px wide by 310px high.
3. If I drag my browser window to different widths, the button width scales but the height does not. This leads to some undesirable effects:  
Starting off pretty slim 1  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/c/ec247af9f593dafafba0814ff868b62c43ec3426.png)  
and getting progressively wider  
2 Blank space appears to the right of the group.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/c/2c03a6e4ee00eba7b2aefcc23af9c85b6ed35f56.png)  
3 Then it disappears  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/0/90ca31ee04bfd7f32b91bca0271e35af593661f3.png)  
4 And comes back again.  
At this point the sidebar leaps unrequested onto the page, further screwing up the buttons.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/0/d05d5fcb833ac8b4a016c0592b271684ba620b86.png)

This is with @flowfuse/node-red-dashboard v1.16.0.

Summary of what seem to be issues:  
A **square** button is portrayed as a **rectangle**.  
The width of a button is responsive but the height is not.  
The button font size is not responsive and in some representations it is allowed to overflow.  
The sidebar is displayed at some screen sizes and not at others.  
Once the sidebar has manifested itself, it does not go away again without clicking on the hamburger icon.

It does not seem viable to create a dashboard to use at different screen resolutions, or am I missing something fundamental?

Edit: It seems that one fundamental thing I missed is that changing border-radius from 50% to em or rem units changes the button from elliptical to a much nicer oval.

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [10 September 2024 15:07 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/2 "2024-09-10T15:07:52Z")

</div>

> [@jbudd](#):
>
> Perhaps foolishly, I expected a 1x1 or 2x2 button to be square, but it's rectangular. Why? Is there a way to configure the template so they will become square?

Which layout style are you using? For "Grid" the width drives the number of columns the button renders at, which will the vary the `px` width, depending on the width of your screen.

If using "Fixed" layout, then I think we do have discrepancies here, that I agree, should be consistent

> [@jbudd](#):
>
> 2 Blank space appears to the right of the group.

This is a result of the "Breakpoints" and the driver of how we handle responsiveness in Dashboard 2.0

You can read more about them [here](https://dashboard.flowfuse.com/layouts/types/grid.html#breakpoints). The TLDR is that we render a different number of columns at different screen widths in order to maintain a sensible layout automatically.

If you want sizes to be consistent (as in `px` consistent) then you can use the "Fixed" layout.

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [10 September 2024 15:08 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/3 "2024-09-10T15:08:28Z")

</div>

> [@jbudd](#):
>
> The button font size is not responsive and in some representations it is allowed to overflow.

Please do open an issue for that, that is a bug.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [10 September 2024 15:10 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/4 "2024-09-10T15:10:42Z")

</div>

> [@joepavitt](#):
>
> Which layout style are you using?

I'm pretty sure it's "Grid" but I can't verify that since after upgrading to v 1.16.0 the dashboard 2 sidebar is blank

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/f/1fca7cbc395fa4b56b2328a318e14693ca5e028e.png)

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [10 September 2024 15:17 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/5 "2024-09-10T15:17:32Z")

</div>

> [@joepavitt](#):
>
> that is a bug.

Forgive me if I'm misunderstanding you Joe.

Are you suggesting that a 1x1 button not getting rendered square is not a bug?  
What about the non-responsive height?  
The intrusive sidebar?

---

<div class="post-metadata">

### Author: ![joepavitt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/joepavitt/32/59722_2.png) [@joepavitt](https://discourse.nodered.org/u/joepavitt)
#### Post date: [10 September 2024 15:21 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/6 "2024-09-10T15:21:26Z")

</div>

I was referring to the text overflow, sorry, should have been clearer in my quotation.

The not square if a side effect of the grid layout (although I think there are frustration in 'Fixed" too which we need to investigate).

The non responsive height is very much by design. If you have a Form/Table with _n_ rows, the wider the screen gets, the height of each row should not change.

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [10 September 2024 15:39 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/7 "2024-09-10T15:39:02Z")

</div>

It is possible to do square button but it is unreasonable to provide as default behaviour cos the responsiveness has strategy and there can be only one strategy in use at the time.

So the strategy is that all elements (widgets) are also responsive. (to some extent at least) That way it is possible to make layout without need to manage inconsistent free space around widgets.

Other kind of problem rises up if that square thing tries to be responsive. So it grows according to space available. In both directions. So the row it is in grows in height. But if something is next to it, it also should do something to still look nice and commonly still provide balanced layout. That kind of situations can't be predicted thus nothing can't be provided as for common layout with zero coding needed.

It is also possible to make your own layout in all levels of the container system the dashboard provides. It is pretty complicated and it heavily depends on content. Thus it is not something I can just point out how to do.  
It takes to have clear vision of the page.Most useful is to start with planning with pen and paper.  
And then it's mostly the CSS.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [10 September 2024 15:39 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/8 "2024-09-10T15:39:03Z")

</div>

> [@jbudd](#):
>
> I'm pretty sure it's "Grid" but I can't verify that since after upgrading to v 1.16.0 the dashboard 2 sidebar is blank

Can you check your console Joe:  
I fixed this last month - [Blank Sidebar when def icon is a function (subflows) · Issue #1195 · FlowFuse/node-red-dashboard · GitHub](https://github.com/FlowFuse/node-red-dashboard/issues/1195)

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [10 September 2024 16:14 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/9 "2024-09-10T16:14:22Z")

</div>

@hotNipi I have seen many examples of your work on dashboards which show your appreciation of the aesthetics.

> [@hotNipi](#):
>
> It is unreasonable to provide [a square button] as default behaviour ... there can be only one strategy in use at the time.

I don't agree.  
There is a grid. It should be square and (if the browser window is big enough) it should be rendered square.  
Of course you are right that when things get shuffled around something has to give.

A half round gauge retains it's proportions at different screen sizes.  
Well of course it does, a gauge is a strongly visual element which would look ridiculous if it was stretched.  
The payoff is that the gauge gets extra white space above it.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/971f9e7d065a3e48df53e8756e24ff9dc31a6e6e.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a85df5b15a55f7a92da262df131c858c1a93ff88.png)

Is a button not also a strongly visual element?  
If it's a default button, a coloured rectangle 1 unit high then the answer is no, it's more like a simple text element.  
But buttons don't have to be simple coloured rectangles.  
This is a dashboard 1 button I've been using for years.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/0/a0665427528efcb36e0e995c2a14f8fba1b55321.png)  
I can't use this on dashboard 2 because a) It does not display as a circle (in a square) _at any screen resolution_ b) change the resolution and it's going to be stretched into various elliptical shapes.

Do we need to have two different dashboard widgets, a button which stays in proportion and a button which stretches to fill the space allocated to it?

---

<div class="post-metadata">

### Author: ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)
#### Post date: [10 September 2024 16:43 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/10 "2024-09-10T16:43:11Z")

</div>

> [@jbudd](#):
>
> Of course you are right that when things get shuffled around something has to give.

Oh no. Same rights for every HTMLElement please!!!

> [@jbudd](#):
>
> I can't use this on dashboard 2 because a) It does not display as a circle (in a square)

Here's the layout is forced to behave to have 5 square buttons and the last column has buttons to fill the rest of space available. Square buttons have defined width and aspect ratio 1.

It takes to have CSS override for that group and for buttons which land on those square slots.

```auto
.special-grid .nrdb-layout-group--grid{
    grid-template-columns: 48px 48px 48px 48px 48px 1fr !important;
}
.square-button{
    aspect-ratio: 1;
    width: var(--widget-row-height);
}

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/a/9abf9a1e6dc20aa75cb41745702bd78358ea37cc.png)

So it is entirely possible to have square buttons but it takes also to manage the surroundings somehow. So it is so called "dedicated design". Common solutions can't be built with such kind of options in mind. It is not manageable and not predictable.

---

<div class="post-metadata">

### Author: ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)
#### Post date: [10 September 2024 17:10 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/11 "2024-09-10T17:10:47Z")

</div>

Providing a user-configurable dashboard that truly 'listens' to the user is superhard. Especially when applying a gridsystem and dealing with responsive layouts. As masonry is not an option (yet) (although you could use a column layout as well, at the cost of horizontal alignments), you always end up with dealing with row heights, but why the same height is applied to a button puzzles me.

The only interface that truly nailed it, is Grafana, which actually using something similar to gridstack, which (un)ironically the node-red-dashboard uses for the layout of the widget.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [10 September 2024 19:57 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/12 "2024-09-10T19:57:18Z")

</div>

> [@jbudd](#):
>
> But buttons don't have to be simple coloured rectangles.  
> This is a dashboard 1 button I've been using for years.  
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/0/a0665427528efcb36e0e995c2a14f8fba1b55321.png)

Could you post a mini flow using that please, so I can have a play with it?

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [10 September 2024 20:29 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/13 "2024-09-10T20:29:40Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/4/741ce12cf0f2f00616015c17bdca394abc769553.png)

Edit: code reposted further down the thread

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [10 September 2024 20:51 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/14 "2024-09-10T20:51:38Z")

</div>

That appears to be just a D1 template node, I meant your attempts to make it work in D2, which give the effect that you have described.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [10 September 2024 21:14 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/15 "2024-09-10T21:14:10Z")

</div>

> [@Colin](#):
>
> That appears to be just a D1 template node

No, it's a simple button node with a bit of CSS.

My attempts to migrate it to the new dashboard go no further than my original post illustrating a button with/without border-radius 50% producing an unattractive result.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [10 September 2024 21:18 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/16 "2024-09-10T21:18:45Z")

</div>

> [@jbudd](#):
>
> No, it's a simple button node with a bit of CSS.

I can only see the ui\_template, ui\_group and ui\_tab in the export.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [10 September 2024 21:19 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/17 "2024-09-10T21:19:46Z")

</div>

Oops, try this

```auto
[{"id":"20d45887.d8ef1","type":"ui_button","z":"69594495cf1ea8a1","name":"Button","group":"5b5ee9f169c93ecf","order":1,"width":2,"height":2,"passthru":false,"label":"","tooltip":"","color":"{{foreground}}","bgcolor":"#eeeeee","className":"round","icon":"fa-power-off fa-4x","payload":"toggle","payloadType":"str","topic":"","topicType":"str","x":450,"y":80,"wires":[["46b4fb8b97653bf0","36ac183f82ba116c"]]},{"id":"f8088574.aea0e8","type":"ui_template","z":"69594495cf1ea8a1","group":"5b5ee9f169c93ecf","name":"CSS","order":8,"width":0,"height":0,"format":"<style id=\"round-button\">\n.round i {\n\ttext-shadow:\n\t-1px -1px 1px #444444,\n\t1px -1px 1px #444444,\n\t-1px 1px 1px #444444,\n\t1px 1px 1px #444444,\n\t0px 0px 10px #888888;\n}\n/* round button */\n.round button {\n border-radius:50%;\n border-style:solid;\n border-width: 3px;\n border-color: #888888;\n}\n.nr-dashboard-button.round { \nmargin-left: 10px !important;\n}\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","className":"","x":450,"y":40,"wires":[[]]},{"id":"46b4fb8b97653bf0","type":"debug","z":"69594495cf1ea8a1","name":"Button press","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":610,"y":80,"wires":[]},{"id":"36ac183f82ba116c","type":"function","z":"69594495cf1ea8a1","name":"Change foreground","func":"msg.foreground = context.get(\"buttonstate\") || \"white\"\nif (msg.foreground === \"white\") {\n msg.foreground = \"red\"\n}\nelse {\n msg.foreground = \"white\"\n}\ncontext.set (\"buttonstate\", msg.foreground)\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":270,"y":80,"wires":[["20d45887.d8ef1"]]},{"id":"5b5ee9f169c93ecf","type":"ui_group","name":"demo","tab":"195948bb680041dd","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"195948bb680041dd","type":"ui_tab","name":"Demo","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [10 September 2024 21:21 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/18 "2024-09-10T21:21:36Z")

</div>

OK, I will have a look in the morning, hopefully.

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [10 September 2024 23:28 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/19 "2024-09-10T23:28:35Z")

</div>

> [@hotNipi](#):
>
> It is also possible to make your own layout in all levels of the container system the dashboard provides. It is pretty complicated and it heavily depends on content. Thus it is not something I can just point out how to do.  
> It takes to have clear vision of the page.Most useful is to start with planning with pen and paper.  
> And then it's mostly the CSS.

Surely if you need to go to those lengths, you'd have to consider hard whether Dashboard was the right tool for the job?

Dashboard's main job is surely to be quick and easy to get started. It probably won't be the best tool if you need very specific page designs since you will have to undo or work around much of the baseline of the Dashboard.

> [@jbudd](#):
>
> I don't agree.  
> There is a grid. It should be square and (if the browser window is big enough) it should be rendered square.  
> Of course you are right that when things get shuffled around something has to give.

I suspect that there may be a misunderstanding here - the difference between a mathematical grid and a CSS grid layout. There is no assumption of squareness in a CSS grid. It is really a kind of dynamic layout.

If you want true square/circular elements inside a CSS grid, you must make the object a child of the grid cell and give it explicit sizing. Then you will probably need to decide on positioning within the cell to allow for the varying whitespace around it. I don't really know the details of how buttons are specified within Dashboard to say whether that is done.

Here, for example, is the visual grid layout from a recent example of mine:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/423973a844fd43bdc861887d91c18af267891d5a.png)

And here is the specification for it:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/f/af759966e3eb064fe4d02656c568ac65efda8b48.png)

As you can see, the grid is 12 columns by "auto" rows and the cells are far from square which is to be expected since the rows auto-size to fit the tallest cell entry for each specific row.

If I wanted a square button inside one of those cells, I would have to explicitly size the button.

Here is a quick example:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/b/9ba7ee16e0e5a8fbd05457c8bd512b11052b435f.png)

The HTML is simply:

```html
<article style="--article-width: 7;">
    <h2>Card 5</h2>
    <p>
        This has an overridden width, see the HTML. Sets the number of grid columns used, there are 12 total in the default example but you can change this to anything in the CSS file.
    </p>
    <button class="square">Square dude!</button>
</article>

```

And the extra CSS is:

```css
.square {
    width: 5em;
    height: 5em;
}

```

Set with `em` sizing so that it resizes on zoom or other user-settings.

Or even better, specify as:

```css
.square {
    width: var(--sq, 5em);
    height: var(--sq, 5em);
}

```

Then you can override the default the size easily in HTML:

```html
<button class="square" style="--sq: 10em;">Square dude!</button>

```

Sometimes I love CSS! 😀

---

<div class="post-metadata">

### Author: ![gerry](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gerry/32/21604_2.png) [@gerry](https://discourse.nodered.org/u/gerry)
#### Post date: [11 September 2024 02:52 UTC](https://discourse.nodered.org/t/the-shape-of-a-button/90853/20 "2024-09-11T02:52:17Z")

</div>

@jbudd I still cannot import your code into dashboard 2, unknown ui\_template. unknown ui\_button

[Next page](https://discourse.nodered.org/t/the-shape-of-a-button/90853.md?page=2)
