Make a Link into a Button (with colors, sizes, and icon)
Tue Aug 13 2024 18:46:52 GMT+0000 (Coordinated Universal Time)
Saved by
@cherylcolan
#html
#css
#hyperlink
#button
#colors
#icons
<a class="icon-download btn btn-primary" href="https://[the URL]">Download</a></p>
content_copyCOPY
You can leverage the built-in CSS of the Canvas LMS to create buttons in your content. The buttons will mimic the user interface elements of Canvas. In practice, you want the button to "do" something when you click it, which generally means the button is a hyperlink you want to call attention to.
The example code above creates a link that looks like a blue button with a download icon (looks like a down-pointing arrow) to the left of the word "Download" inside the button. To achieve a similar result, you need to apply a combination of classes for button color, size (optional), icon name, and icon style (optional) to the anchor (<a>) element.
Process: Don't copy the code above, just look at the ```class="..."``` since this is what you need to recreate in Canvas. In the Canvas Rich Content Editor, create a hyperlink (to a course file, course navigation, external link, or other) as you normally do in Canvas. Then, switch to code view and add classes to the anchor element. You will not see your button in the Rich Content Editor. It will appear like a normal link. But when you save, the button will render in the saved content.
Colors
-------
| name | color | class |
| ------- | ------ | ----- |
| default | light gray | .Button |
| primary | blue | .Button--primary |
| secondary | dark blue | .Button--secondary |
| success | green | .Button--success |
| warning | orange | .Button--warning |
| danger | red | .Button--danger |
| link | blue text link | .Button--link |
| icon | (icon) | .Button--icon-action |
Note: in practice, I have been able to use .btn instead of .Button and use a single hypen instead of two. For example, ```class="btn btn-primary"``` to create a blue button.
Sizes
-----
| size | class |
| ---- | ----- |
| large | .Button.Button--large |
| default | default |
| small | .Button.Button--small |
| mini | .Button.Button--mini |
Icon Styles
------------
Canvas icons are created in two weights: line and solid.
| weight | class |
| ------- | ----- |
| line | .icon-Line |
| solid | .icon-Solid |
You also need to include the class of the icon's name, for example "icon-trash" for the trash can icon. To see the available icons and their names, go to: https://instructure.design/#iconography
As of August 2024, the Canvas style guide still shows visual examples of each style and size of button in the normal, active, and disabled states. View them at the URL below and scroll to the Buttons section. Also, view the Icons section for more information.
https://maricopa.instructure.com/styleguide
Comments