V9 of Microsoft's FluentUI library, built for F# in the style of Feliz.


Keywords
.NET, F#, FS, FSharp, Fable, Feliz, FluentUI, dotnet, fluentui-component, fluentuiv9, v9
License
MIT
Install
Install-Package FS.FluentUI -Version 1.4.0

Documentation

FS.FluentUI

V9 of Microsoft's FluentUI (React) made for F# in the style of Feliz

NuGet version (FS.FluentUI) NuGet Downloads

DataGridGif

Please see all F# component examples in the FS.FluentUI Wiki

Please check Microsoft's documentation for further component usage and descriptions

Overview

Fluent UI React Components is a set of UI components and utilities resulting from an effort to converge the set of React based component libraries in production today: @fluentui/react and @fluentui/react-northstar.

Each component is designed to adhere to the following standards:

  • Customizable: Fluent-styled components by default, but easy to integrate your own brand and theme
  • Performance: Optimized for render performance
  • Bundle size: Refactored and slimmed down components that allow you to include the packages and dependencies you need
  • Accessibility: WCAG 2.1 compliant and tested by trusted testers
  • Design to Code: Stay up to date with Fluent Design Language changes via Design Tokens

NOTE: Some components/ functions are incomplete or still considered Preview Components and/or unstable by Microsoft. Please feel free to send PR's in order to get this library as close to 100% as possible!

Place a Fui.fluentProvider at the root of your app and pass the theme in as a prop. You can use pre-determined themes, or create your own BrandVariants or Tokens to use for your theme. See the wiki for specific examples.

open Feliz
open Browser.Dom
open FS.FluentUI
open FS.FluentUI.V8toV9

let useStyles =
    Fui.makeStyles<{| toggleButtons: string |}> [
        "toggleButtons", [
            style.height (length.px 300 )
            style.width (length.px 300)
            style.margin (length.px 50)
            style.border (4, borderStyle.solid, "purple")
        ]
    ]

[<ReactComponent>]
let ToggleButtons () =
    let isChecked1, setIsChecked1 = React.useState true
    let isChecked2, setIsChecked2 = React.useState false

    let styles = useStyles()

    // The use of Fui.stack is preferential and is available through FS.FluentUI.V8toV9
    Fui.stack [
        stack.horizontal false
        stack.horizontalAlign.center
        stack.verticalAlign.center
        stack.tokens [ stack.tokens.childrenGap 16 ]
        stack.className styles.toggleButtons
        stack.children [
            Fui.toggleButton [
                toggleButton.icon (Fui.icon.checkbox1Filled [])
                toggleButton.checked' isChecked1
                toggleButton.onClick (fun _ -> setIsChecked1 (isChecked1 |> not))
                toggleButton.text "Checked state"
            ]
            Fui.toggleButton [
                toggleButton.appearance.primary
                toggleButton.checked' isChecked2
                toggleButton.onClick (fun _ -> setIsChecked2 (isChecked2 |> not))
                toggleButton.text "Unchecked state"
            ]
            Fui.toggleButton [
                toggleButton.shape.circular
                toggleButton.disabledFocusable true
                toggleButton.text "Disabled focusable"
            ]
        ]
    ]

let root = ReactDOM.createRoot (document.getElementById "feliz-app")
root.render (
    Fui.fluentProvider [
        fluentProvider.theme.webLightTheme
        fluentProvider.children [
            ToggleButtons ()
        ]
    ]
)

FSReadMe

Installation

Current NPM dependencies:

  • @fluentui/react-components
  • @fluentui/react-datepicker-compat
  • @fluentui/react-calendar-compat
  • @fluentui/react-timepicker-compat
  • @fluentui-contrib/react-data-grid-react-window

NOTE: If you don't need to use a DatePicker, Calendar (or any Calendar-related functions listed below), TimePicker, or VirtualizedDataGrid component, then the only npm package you need is @fluentui/react-components. Feel free to pick and choose which packages you download according to what components you need or don't need, so long as you have @fluentui/react-components downloaded.

Calendar-related functions that require @fluentui/react-calendar-compat: addDays, addMonths, addWeeks, addYears, setMonth, isInDateRangeArray, getYearStart, getYearEnd, getWeekNumbersInMonth, getWeekNumber, getStartDateOfWeek, getMonthStart, getMonthEnd, getEndDateOfWeek, getDateRangeArray, compareDates, compareDatePart

Install into your Client.fsproj project using Femto (recommended)

cd ./{path to Client}

# when using femto as a global CLI tool
femto install FS.FluentUI

# when using femto as a local CLI tool
dotnet femto install FS.FluentUI

This will install the nuget package and afterwards automatically installs the required npm packages used by this binding.

Femto will detect whether you are using paket and will install the package using paket into the dependency group of the project

You can install the library manually if you want by first installing the nuget package

cd ./{path to your project}
dotnet add package FS.FluentUI
npm install @fluentui/react-components @fluentui/react-datepicker-compat @fluentui/react-calendar-compat @fluentui/react-timepicker-compat @fluentui-contrib/react-data-grid-react-window