fluentui-react-v9-custom-components

Guide for building custom React components using Fluent UI v9 base state hooks and render functions. Use when asked to: create a component based on FluentUI headless hooks, build a custom component using Fluent UI base state hooks, create a component with custom styling that reuses Fluent UI accessibility behavior, implement a component using render{Component}_unstable and use{Component}Base_unstable, or consume @fluentui/react-button/@fluentui/react-tabs/etc. without Fluent 2 visual design.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "fluentui-react-v9-custom-components" with this command: npx skills add dmytrokirpa/fluentui/dmytrokirpa-fluentui-fluentui-react-v9-custom-components

Building Custom Components with FluentUI v9 Base Hooks

Base state hooks + render functions let you reuse Fluent's ARIA behavior, keyboard handling, and slot structure with completely custom styling. Imports come from individual component packages (e.g. @fluentui/react-button), not from @fluentui/react-components.

Your responsibility: custom styling, visible focus indicators, sufficient color contrast, and all visual accessibility. Base hooks provide ARIA structure but not visual a11y.

The Pattern

import * as React from 'react';
import { useButtonBase_unstable, renderButton_unstable } from '@fluentui/react-button';
import type { ButtonBaseProps, ButtonState } from '@fluentui/react-button';

type CustomButtonProps = ButtonBaseProps & {
  variant?: 'primary' | 'secondary' | 'tertiary';
  tone?: 'neutral' | 'success' | 'warning' | 'danger';
};

export const CustomButton = React.forwardRef<HTMLButtonElement, CustomButtonProps>(
  ({ variant = 'primary', tone = 'neutral', ...props }, ref) => {
    // 1. Get state: ARIA, keyboard handling, slot structure
    const state = useButtonBase_unstable(props, ref);

    // 2. Mutate state: apply your classes/styles
    state.root.className = ['btn', `btn--${variant}`, `btn--${tone}`].filter(Boolean).join(' ');
    if (state.icon) {
      state.icon.className = 'btn__icon';
    }

    // 3. Render using Fluent's render function
    return renderButton_unstable(state as ButtonState);
  },
);

Available Hooks

See references/available-hooks.md for the full inventory with import paths, prop/state types, and notes.

Quick reference:

ComponentHookRender functionPackage
ButtonuseButtonBase_unstablerenderButton_unstable@fluentui/react-button
ToggleButtonuseToggleButtonBase_unstablerenderToggleButton_unstable@fluentui/react-button
TabListuseTabListBase_unstablerenderTabList_unstable@fluentui/react-tabs
TabuseTabBase_unstablerenderTab_unstable@fluentui/react-tabs
DivideruseDividerBase_unstablerenderDivider_unstable@fluentui/react-divider
AccordionuseAccordionBase_unstablerenderAccordion_unstable@fluentui/react-accordion
AccordionPaneluseAccordionPanelBase_unstablerenderAccordionPanel_unstable@fluentui/react-accordion
ToolbaruseToolbarBase_unstablerenderToolbar_unstable@fluentui/react-toolbar
ToolbarButtonuseToolbarButtonBase_unstablerenderToolbarButton_unstable@fluentui/react-toolbar
PopoverusePopoverBase_unstablerenderPopover_unstable@fluentui/react-popover
PersonausePersonaBase_unstablerenderPersona_unstable@fluentui/react-persona
CarduseCardBase_unstablerenderCard_unstable@fluentui/react-card

Compound Components (TabList, Accordion)

Compound components require context values passed to the render function. Use use{Component}ContextValues_unstable and inject any design props needed by child components before calling it:

import {
  useTabListBase_unstable,
  useTabListContextValues_unstable,
  renderTabList_unstable,
  useTabListA11yBehavior_unstable,
} from '@fluentui/react-tabs';
import type { TabListBaseProps, TabListState } from '@fluentui/react-tabs';

type CustomTabListProps = TabListBaseProps & { appearance?: 'filled' | 'outline' };

export const CustomTabList = React.forwardRef<HTMLDivElement, CustomTabListProps>(
  ({ appearance = 'filled', ...props }, ref) => {
    const state = useTabListBase_unstable(props, ref);

    // Inject design props consumed by child Tab components via context
    Object.assign(state, { appearance, size: 'medium', reserveSelectedTabSpace: true });
    const contextValues = useTabListContextValues_unstable(state as TabListState);

    // Apply custom classes
    state.root.className = `tab-list tab-list--${appearance}`;

    // Keyboard navigation: choose one approach
    // Option A — Tabster (recommended for accessibility)
    const focusProps = useTabListA11yBehavior_unstable({ vertical: state.vertical });
    state.root = { ...state.root, ...focusProps };
    // Option B — focusgroup proposal
    // (state.root as any).focusgroup = `tablist ${state.vertical ? 'block' : 'inline'} no-memory wrap`;

    return renderTabList_unstable(state as TabListState, contextValues);
  },
);

TypeScript tips

  • Use {Component}BaseProps for the component's props type
  • Cast state to {Component}State when passing to render: renderButton_unstable(state as ButtonState)
  • Child components (e.g. CustomTab) read design values from context via useTabListContext_unstable

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

fluentui-react-v9-base-hooks

No summary provided by upstream source.

Repository SourceNeeds Review
General

test_skill

import json import tkinter as tk from tkinter import messagebox, simpledialog

Archived SourceRecently Updated
General

neo

Browse websites, read web pages, interact with web apps, call website APIs, and automate web tasks. Use Neo when: user asks to check a website, read a web page, post on social media (Twitter/X), interact with any web app, look up information on a specific site, scrape data from websites, automate browser tasks, or when you need to call any website's API. Keywords: website, web page, browse, URL, http, API, twitter, tweet, post, scrape, web app, open site, check site, read page, social media, online service.

Archived SourceRecently Updated
General

image-gen

Generate AI images from text prompts. Triggers on: "生成图片", "画一张", "AI图", "generate image", "配图", "create picture", "draw", "visualize", "generate an image".

Archived SourceRecently Updated