Utility Button
UtilityButton acts as inline page navigation and should always be used in groups of two or more, compared to the Button component which is designed to work as a standalone element and performs the role of a call-to-action (CTA).
Installation
npm install @nib/utility-button
Note: You will also need to install the peerDependencies @nib/icons and @nib-components/theme.
Usage
import UtilityButton from '@nib/utility-button';
Interactive demo
UtilityButton
is a compound component with two sub-components: UtilityButton.Title
and UtilityButton.SubTitle
.
Note: If you are using this component within a React Server Component (like the NextJS 13 App Router), it is suggested to import
UtilityButtonTitle
andUtilityButtonSubTitle
individually.
import UtilityButton, {UtilityButtonTitle, UtilityButtonSubTitle} from '@nib/utility-button';import {DentalGraphicIcon, DownloadSystemIcon} from '@nib/icons';() => (<UtilityButton icon={DentalGraphicIcon} actionIcon={DownloadSystemIcon}><UtilityButtonTitle>Required title</UtilityButtonTitle><UtilityButtonSubTitle>Optional subtitle</UtilityButtonSubTitle></UtilityButton>);
Props
UtilityButton
Prop | Type | Default | Description |
---|---|---|---|
icon | component | An icon to be displayed on the left of the button, to communicate the context or intent of the button. Must be a graphic icon from the @nib/icons package. | |
showBorder | boolean | true | Option to display a border. |
selected | boolean | false | Option to change utility button state to selected state. Adds border and Updated Title color when its true |
disabled | boolean | false | Option to identicate the disabled state of the utility button |
showActionIcon | boolean | true | Option to display the chevron. |
actionIcon | component | ChevronRightSystemIcon | An icon to be displayed on the right of the button, to communicate the function of the UtilityButton . Must be a system icon from the @nib/icons package. |
href | string | Add a link to the button. Note that the component is rendered as an <a> tag in the DOM. | |
onClick | function | If the component is required to carried out some complex functionality other than linking | |
component | string or node | What to render the utility button as. Should be either a button or a . If onClick is not supplied, will defaults to a | |
children (required) | node | Should include a UtilityButton.Title and optionally a UtilityButton.SubTitle |
UtilityButton.Title & UtilityButton.SubTitle
Prop | Type | Default | Description |
---|---|---|---|
truncate | boolean | false | Option to truncate the title and subtitle. Given this component is a CTA truncating the label is not recommended. |
children (required) | string | The text for the utility button. |
Usage
Single UtilityButtons should not be used
Props used on one UtilityButton should be carried through to all other UtilityButtons within the group. So for example, if an icon is included in one UtilityButton, then all UtilityButtons should include an icon. All UtilityButtons used in a group should be uniform.
Be conscious of the number of UtilityButton components you have in a group and the impact that has on available space for the title/subtitle. Within our Container component we've found that 4 - 5 is the most that can comfortably fit. If using icons, this drops down to 3 - 4. If including close to the maximum number of utility buttons be sure to set collapseBelow
on the Columns
component to xl
or xxl
.
A UtilityButton should be used on either a White or Lightest background. When the UtilityButton is placed on a White background, then border should be shown.
Multiple utility buttons
Utility buttons with selected state
Multiple utility buttons with icons
Note: The
Columns
andColumn
with theflex
prop is how we achieve equal heights for the utility buttons when the content lengths differ.