Fluent 2 is Microsoft's modern design system that provides a comprehensive set of design tokens and components

Fluent 2 is Microsoft's modern design system that provides a comprehensive set of design tokens and components

Fluent 2 is Microsoft's modern design system that provides a comprehensive set of design tokens and components. This guide will help you get started with implementing Fluent 2 in your projects.

What is Fluent 2 Design System?

Fluent 2 is Microsoft's design system that emphasizes clarity, efficiency, and beauty. It provides:

Why Choose Fluent 2?

Getting Started with Fluent 2

1. Understanding Design Tokens

Design tokens are the foundation of Fluent 2. They define colors, typography, spacing, and other design properties. Here's how to use them:

/* Using Fluent 2 color tokens */
.button {
    background-color: var(--fluent-color-brand-primary);
    color: white;
    padding: var(--fluent-spacing-m);
    border-radius: var(--fluent-border-radius-medium);
}

2. Color System

Fluent 2 provides a carefully crafted color palette for light and dark modes:

/* Light mode (default) */
:root {
    --fluent-color-brand-primary: #0078d4;
    --fluent-color-text-primary: #242424;
    --fluent-color-background-primary: #ffffff;
}

/* Dark mode */
[data-theme="dark"] {
    --fluent-color-brand-primary: #60a5fa;
    --fluent-color-text-primary: #ffffff;
    --fluent-color-background-primary: #1f1f1f;
}

3. Typography

Fluent 2 defines a typography scale for consistency:

h1 {
    font-size: var(--fluent-font-size-xxlarge);
    font-weight: var(--fluent-font-weight-bold);
    line-height: 1.2;
}

p {
    font-size: var(--fluent-font-size-base);
    line-height: 1.6;
}

4. Spacing

Fluent 2 provides consistent spacing values:

/* Spacing tokens */
--fluent-spacing-s: 8px;
--fluent-spacing-m: 16px;
--fluent-spacing-l: 24px;
--fluent-spacing-xl: 32px;
--fluent-spacing-xxl: 48px;

Building Components

Here's an example of a Fluent 2-compliant button component:

<button class="fluent-button fluent-button-primary">
    Get Started
</button>
.fluent-button {
    padding: var(--fluent-spacing-m);
    border-radius: var(--fluent-border-radius-medium);
    font-weight: var(--fluent-font-weight-semibold);
    border: none;
    cursor: pointer;
    transition: all var(--fluent-animation-duration-fast);
}

.fluent-button-primary {
    background-color: var(--fluent-color-brand-primary);
    color: white;
}

.fluent-button-primary:hover {
    background-color: var(--fluent-color-brand-secondary);
}

Dark Mode Implementation

Fluent 2 includes comprehensive dark mode support. Toggle it with a data attribute:

// Toggle dark mode
document.body.setAttribute('data-theme', 'dark');

// All CSS variables automatically adjust based on [data-theme] selector

Best Practices

Resources

Conclusion

Fluent 2 provides a robust foundation for building consistent, accessible, and beautiful applications. By leveraging its design tokens and guidelines, you can create professional interfaces that work seamlessly across platforms. Whether you're building for enterprise or consumer applications, Fluent 2 offers the flexibility and polish needed for modern web design.

Start exploring Fluent 2 today and elevate your design system to the next level!