Language: EN

fast-design

Easily Develop Web Applications with WebComponents and FAST Design

FAST Design is a collection of open-source web tools and components developed by Microsoft, designed to help us build modern, fast, and accessible web interfaces.

FAST, which stands for Flexible and Scalable Toolkit, is built on principles of modularity and extensibility. This means it allows us to adapt and customize components according to the specific needs of our projects.

It is compatible with multiple technologies and frameworks, including Vanilla, React, Vue, Angular, ASP.NET, and Blazor, among others.

Some of the main features of FAST Design are:

  1. Modularity: FAST components are modular, allowing us to include only what we need, reducing the weight of dependencies and improving performance.
  2. Accessibility: FAST focuses on accessibility, ensuring that components meet web accessibility standards (WCAG).
  3. Customization: The components are highly customizable through styles and configurations, allowing for seamless integration with the visual design of our applications.
  4. Performance: Optimized for performance, FAST components are lightweight and designed to load and execute quickly.

For more information about FAST Design, we can consult the official FAST documentation and explore the repository on GitHub for additional examples and source code.

Installing FAST Design

To start using FAST Design in our project, we first need to install the necessary packages. We can do this using npm, the package manager for Node.js.

We execute the following command at the root of our project:

npm install --save @microsoft/fast-components

With the packages installed, we are ready to start using FAST Design in our application.

How to Use FAST Design

Using Predefined Components

FAST Design provides a variety of predefined components that we can use directly in our application. Let’s look at some examples of how to use some of these components, such as buttons and text fields.

import { provideFASTDesignSystem, fastButton, fastTextField } from '@microsoft/fast-components';

provideFASTDesignSystem()
    .register(fastButton(), fastTextField());

document.body.innerHTML = `
  <fast-button>Click me</fast-button>
  <fast-text-field placeholder="Enter text here"></fast-text-field>
`;

In this example, we use provideFASTDesignSystem to register the fastButton and fastTextField components, and then we use them in the HTML of our application.

Creating a Basic Component

To demonstrate how to use FAST Design, we will create a basic web component. First, we define a custom component using @microsoft/fast-element and @microsoft/fast-foundation.

import { FASTElement, customElement, html } from '@microsoft/fast-element';

const template = html`
  <div>
    <h1>Hello, FAST Design</h1>
    <p>This is a basic component created with FAST Design.</p>
  </div>
`;

@customElement({ name: 'hello-fast', template })
class HelloFast extends FASTElement {}

In this example, we use FASTElement to define our component and customElement to register the component with the name hello-fast. The template defines the HTML structure of the component.

Styling Customization

We can customize the styles of FAST Design components using CSS. Below is an example of how to apply custom styles to a button.

<fast-button class="custom-button">Custom Button</fast-button>

<style>
  .custom-button {
    background-color: #0078d4;
    color: white;
    border-radius: 4px;
    padding: 10px 20px;
  }
</style>

In this example, we apply custom styles to the fast-button using the custom-button class.