Big Buttons

How to add big buttons to your application to improve navigation

Some big buttons with fa icons

The JS

Add this constant before the Single Sign On JS code. This will typically be on the first line of the custom JS in your Knack web application unless you are importing any JS libraries or scripts.

You must use backtick temporal literals (not single quotes) for the constant and the URL. You can read about temporal literals in the MDN documentation for more information.

For the bigButton() function, put it before the handlers.

For the handler, incorporate the constant with the JS below if you are redirecting to the same Knack application. This is so that if you have to copy the app for testing, the big button will redirect to the copied app URL.

Previous JS - Before August 2025

Big Buttons are nested in an <a> tag now instead of a <div> tag so that the clickable area of buttons does not expand the width of the Knack page and stays within the button area. The variable newTab has been added if you would like a big button to open its url in a new tab. To do this you would pass the true argument to the individual button. Additionally, the variable disabledClass has been added if you would like to set a big button to be disabled. To do this you would pass the true argument to the individual button. This code also lives in the common folder in the atd-knack GitHub repository.

A handler for each big button.

To open a big button in a new tab, pass the true argument in the handler like this

To disable a big button, pass the true argument in the handler after the newTab argument

To do both, open in a new tab and disable the button, pass the true argument for both

The CSS

Big Buttons have shadow to show elevation and provide a 3D effect. They are also display: block so we can set width without clickable area extending the width of the page. We create a pointer hover and color effect when enabled and an opacity and cursor effect when disabled. These CSS classes only need to placed once on the CSS page and any buttons can use them. They can be called via JS or HTML.

Add these CSS classes if not already present. If we have a disable button it allows us to change the mouse pointer and set the Font Awesome icons throughout the app to the middle of the line vertically.

How to Implement Big Button code

1

Create a Rich Text view

Go pages and create a rich text view on the page. This is where the big button will be created.

2

Find View ID of the rich text view

Open the Rich Text view to identify its View ID and update the view name to include it for easy reference

3

Add Custom CSS

Make sure the CSS styling is in place. Update the CSS styling to meet your needs, sometimes buttons may need a larger width to accommodate your button text. Additionally, if you already have the disabled and fa CSS classes, be sure not to duplicate them.

4

Add Custom JS

When placing the JS, the function only needs to be placed once but you will need a new handler for each Rich Text view + Big Button that you have.

Things to change in JavaScript

  • Change the Button ID in the first set of parentheses to whatever is appropriate to name your button;

  • Change the View ID to match the corresponding Rich Text view where the big button will live;

  • Change the URL to the corresponding page that the button will redirect to. Make sure this uses back ticks.

  • Change the Font Awesome icon to match the theme of the button. Knack currently supports FA version 4 icons. You can also read more about FA icons here.

  • Change the Button Label of the button to the text that will be visible;

  • Add the true argument if you would like the button to open in a new tab;

  • Add the true argument after the newTab argument if you would like the button to be disabled

Last updated

Was this helpful?