Skip to content
3.0 Partas.Solid now targets Solid 2

Solid components,
written in F#

A typed F# DSL and a Fable compiler plugin that turns your components into the JSX Solid expects, with no runtime of its own.

dotnet add package Partas.Solid --version 3.0.0

3.0 is a prerelease and is not on NuGet yet. Install it from a local feed.

Try it

Every example on this site is compiled from its F# when the site is built. Fable and the Partas plugin produce JSX, Solid's compiler turns it into DOM code, and it runs in your browser. This one also uses anime.js from npm.

[<SolidComponent>]
let HeroCounter () =
    let count, setCount = createSignal 0
    let mutable number: HTMLSpanElement = JS.undefined
    let mutable bars: HTMLDivElement = JS.undefined

    let pop = {| scale = {| from = 1.4; ``to`` = 1 |}; ease = "outElastic(1, .5)" |}
    let wave =
        {| scaleY = {| from = 1; ``to`` = 2.6 |}; duration = 240
           alternate = true; loop = 1
           delay = stagger (30, {| from = "center" |}) |}

    let bump () =
        setCount (count () + 1)
        animate (number, pop) |> ignore
        animate (bars.children, wave) |> ignore

    div (class' = "p-demo__stage") {
        span(class' = "p-demo__count").ref (number) { $"{count ()}" }
        div(class' = "p-demo__bars").ref (bars) {
            Repeat(count = 13) { yield fun _ -> span () }
        }
        button (class' = "p-btn p-btn--accent", onClick = fun _ -> bump ()) {
            "Increment"
        }
    }
export function HeroCounter() {
    const patternInput = createSignal(0);
    const count = patternInput[0];
    let number = void 0;
    let bars = void 0;
    const pop = {
        ease: "outElastic(1, .5)",
        scale: {
            from: 1.4,
            to: 1,
        },
    };
    let wave;
    const scaleY = {
        from: 1,
        to: 2.6,
    };
    wave = {
        alternate: true,
        delay: stagger(30, {
            from: "center",
        }),
        duration: 240,
        loop: 1,
        scaleY: scaleY,
    };
    return <div class="p-demo__stage">
        <span class="p-demo__count"
            ref={number}>
            {`${count()}`}
        </span>
        <div class="p-demo__bars"
            ref={bars}>
            <Repeat count={13}>
                {(_arg) => <span />}
            </Repeat>
        </div>
        <button class="p-btn p-btn--accent"
            onClick={(_arg_1) => {
                patternInput[1](count() + 1);
                animate(number, pop);
                return animate(bars.children, wave);
            }}>
            Increment
        </button>
    </div>;
}

Why Partas.Solid

Write the whole front end in F#, and ship ordinary Solid code.

The Partas family

Open source F# front-end projects, built on Fable and Solid.

Write your first component

Set up Fable, the packages and Vite, then learn the two ways to write a component.