@visual-framework/vf-button

    2.0.0-alpha.5 • Public • Published

    Button component

    npm version

    About

    Buttons are clickable elements that trigger an action. They can communicate calls to action, are visually prominent, and allow users to interact with the pages in various ways.

    Usage

    The vf-button component can be used with forms on a page and as a prominent 'call to action' link that goes to another page.

    When To Use

    A button can be used to submit data or take action and as a link to navigate to another page.

    Use the primary button for the principal call to action on a page or form. Avoid having multiple primary buttons on the same page or form.

    Use secondary buttons for secondary calls to action. Pages with too many prominent calls to action make it hard for users to know what to do next. Before adding lots of secondary buttons, try to simplify the page or break the content down across multiple pages.

    Tertiary buttons can be used for less prominent actions. Consider using a link instead of a button to send users to another page, if this action is not very important.

    As the vf-button is relatively large, depending on the context, you may wish to use the vf-button--small variant instead.

    Alignment

    As a general rule, the vf-button should be left aligned on the page and when used inside a larger component.

    When used in conjunction with a single form input, as in the vf-search component, the vf-button needs to be inline with the input and to the right of it.

    When a vf-button is used in a banner (e.g. to accept cookies) it needs to follow the content and be right aligned.

    When Not To Use

    If using the vf-button as a link do not use it to link to content on the same page. Use the vf-link-list component instead.

    Label

    Write button text in sentence case, describing the action it performs. For example:

    • ‘Apply now’ to apply for a job.
    • ‘Create account’ to create an account.
    • ‘Sign in’ to an account that a user has already created.
    • ‘Save and continue’ when pressing the button will save the information that the user has entered.

    Try to keep the text on the button short and clear.

    Related documentation

    The guidelines on buttons in the GOV.UK Design System and the Carbon Design System include additional advice on when and how to use buttons.

    Angular

    As of vf-button v2.0.0-alpha.2 vf-button has experimental Angular support.

    1. install yarn add @visual-framework/vf-button
    2. import in your app.module
      import { VfButton } from "@visual-framework/vf-button/vf-button.angular.component.ts";
      
      @NgModule({
        declarations: [VfButton, YourOtherComponents],
        ...
      })
      
    3. use
      <a vf-button href="//embl.org" primary="true" small="true">Hello world</a>
      
    4. add to your styles.scss
      @import '~@visual-framework/vf-button/vf-button.scss';
      
      (you should also make use of vf-sass-starter)

    Depending on the success of this method, we plan to add standardized guidance to the component library and component generator.

    Usage:

    <a vf-button href="//embl.org" primary="true" small="true">Hello</a>

    Install

    This component is distributed with npm. After installing npm, you can install the vf-button with this command.

    $ yarn add --dev @visual-framework/vf-button
    

    Sass/CSS

    The source files included are written in Sass(scss). You can point your Sass include-path at your node_modules directory and import it like this.

    @import "@visual-framework/vf-button/index.scss";
    

    Make sure you import Sass requirements along with the modules. You can use a project boilerplate or the vf-sass-starter

    Help

    Install

    npm i @visual-framework/vf-button

    DownloadsWeekly Downloads

    801

    Version

    2.0.0-alpha.5

    License

    Apache 2.0

    Unpacked Size

    44.6 kB

    Total Files

    15

    Last publish

    Collaborators

    • khawkins98