Create consistency in actions and clearly described and familiar actions on each page...
Buttons allow the user to perform an action on the page.
The intent
attribute is used to indicate the role of the button which will affect how it is styled according to your theme.
Currently, the following themed options are supported:
If you add instances of neutral buttons to your project, it is strongly recommended that they are not added to the bottom of workflows and that they are not paired with either workflow-primary
or workflow-secondary
buttons.
<q2-btn intent="workflow-secondary">
Secondary button
</q2-btn>
<q2-btn intent="workflow-primary">
Primary button
</q2-btn>
<q2-btn intent="neutral">
Neutral button
</q2-btn>
You can easily add icons to your buttons in the same way you would add text. Tecton's implementation of this is pretty simple and allows you to show icons in three different ways.
Just add the q2-icon
directly to the button's inner HTML.
<q2-btn intent="workflow-primary">
<q2-icon type="edit"></q2-icon>
</q2-btn>
Add the q2-icon
as the first element in the button's inner HTML, followed by a span
containing the text to be displayed in your button.
<q2-btn intent="workflow-primary">
<q2-icon type="edit"></q2-icon>
<span>Edit</span>
</q2-btn>
Add the q2-icon
as the last element in the button's inner HTML, followed by a span
containing the text to be displayed in your button.
<q2-btn intent="workflow-primary">
<span>Edit</span>
<q2-icon type="edit"></q2-icon>
</q2-btn>
Note: Tecton ensures that only one icon is displayed per button.
While not recommended, it is possible to use custom icons within a q2-btn
component, if the one you need is not provided by the Tecton Icon. To do so, we recommend inlining the SVG code for your icon to help take advantage of theming properties provided by Tecton, like the example below:
<q2-btn intent="workflow-primary">
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
style="width: var(--tct-icon-size, 24px); height: var(--tct-icon-size, 24px); stroke: currentcolor;">
<path d="M2 22 22 2M2 13 13 2M4 2 2 4M11 22l11-11M22 20l-2 2"/>
</svg>
<span>Circle Icon Button</span>
</q2-btn>
You can use q2-btn
as an unstyled semantic button
. Simply omit all optional attributes such as intent
, icon
, badge
, and block
to use an unstyled q2-btn
.
Some guidelines for using unstyled buttons:
q2-btn
, not on the button itself.<q2-btn>
An unstyled q2-btn 👋
</q2-btn>
The q2-btn
element has one slot that can be used to insert custom content into the component.
An optional slot to display a custom coin button label.
The q2-btn
element has one or more properties that support text localization. Those properties are indicated by the localizable badge in the description.
block
The component expands to fill the width of its parent element.
disabled
Marks the component as disabled and displays a not-allowed
cursor on hover.
hideLabel
hide-label
Hides the label
, and assigns its value to the aria-label
attribute on the <button>
element.
intent
Indicates the role of the component in the workflow, which will apply appropriate styling to the component.
label
Defines the text content of the button if it is not provided in the <slot>
of the element.
Also used for the aria-label
of the <button>
element when only displaying an icon.
loading
Displays the button with a loading spinner to indicate something is happening in the background and the user should not click again.
size
Defines the size of q2-btn, it renders as default size if not provided.
type
The default behavior of the button.
This component uses other components in the Tecton library, including:
q2-loading
Other components in the Tecton library use this component, including:
q2-action-sheet
q2-calendar
q2-carousel
q2-data-table
q2-dropdown
q2-editable-field
q2-file-picker
q2-input
q2-modal
q2-month-picker
q2-pagination
q2-section
q2-stepper
q2-tab-container
Initial Release
This page hosts the rules and guidance around placing buttons in Q2 related products, using the tecton q2-button and its many variants.
Workflows consider:
Create consistency in actions and clearly described and familiar actions on each page...
... avoid Inconsistency in the hierarchy of actions.
The primary action is the most salient action on the page.
Secondary buttons are supporting Actions or "negative" actions
Choosing between using a link or a button in web design depends on the intended action and the context it presents. Here's a breakdown:
In summary, links are generally used for navigation and textual actions, while buttons are used for interactive actions and calls to action. However, the choice should also consider usability and accessibility principles, ensuring that users can easily understand and interact with the elements on the web page.
When a screen reader user encounters a button or link, their screen reader is going to read the HTML tag and tell them if they are on a button or a link, and then read the text or aria-label for that button or link.
So for a link like this: <a href=”/about”>Learn More About Us</a>
, a screen reader user would hear, “Link. Learn more about us.” This is same even if that link were styled to look like a button (for example by adding class=”button” to the link), because the screen reader is using the <a> tag to know that this is a link.
If the element was a button, like this: <button>Close Popup</button>
, they would hear, “Button. Close popup.”
Decorations on buttons can help indicate the user's intent for the action. Icons can become recognizable and memorable symbols for specific actions or functions. Over time, users learn to associate specific icons with particular actions, enhancing usability and efficiency.
Signifiers help users understand the functionality and behavior of objects or elements, reducing cognitive load and enhancing usability.
The following CSS variables are available to override the default theme styles of the q2-btn
component.
Many Tecton components consume other components to maintain visual and functional consistency. If you are looking for a CSS variable you think should exist but are not seeing it, it may be defined in one of the dependent components below. Either way, if you think it's something we should expose more conveniently, let us know!
There are 2 frequently asked questions related to this page.